Hi,
I'd like construct a JFrame with two JPanels,
one using no LayoutManager, as shown below.
When I construct my JFrame with the NORTH JPanel
having no LayoutManager, I'm not able to see my JLabel.
How can I show my JLabel with this arrangement.
Thanks for your help.
Jeff Higgins
import java.awt.*;
import javax.swing.*;
public class LayoutTest
{
LayoutTest() {
JFrame frame = new JFrame("LayoutTest");
JPanel displayPanel = new JPanel();
JPanel controlPanel = new JPanel(new BorderLayout());
// comment following - label is shown
displayPanel.setLayout(null);
JLabel label = new JLabel("Label");
Dimension d = label.getPreferredSize();
label.setBounds(75, 75, d.width, d.height);
displayPanel.add(label);
frame.setSize(200, 200);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(displayPanel, BorderLayout.NORTH);
frame.add(controlPanel, BorderLayout.SOUTH);
frame.setVisible(true);
}
public static void main(String[] args)
{
@SuppressWarnings("unused")
LayoutTest test = new LayoutTest();
}
}
Michael Dunn - 20 Jul 2007 02:35 GMT
> Hi,
> I'd like construct a JFrame with two JPanels,
[quoted text clipped - 4 lines]
>
> How can I show my JLabel with this arrangement.
<snip code>
displayPanel.setLayout(null);
displayPanel.setPreferredSize(new Dimension(200,100));
Jeff Higgins - 20 Jul 2007 02:49 GMT
>> Hi,
>> I'd like construct a JFrame with two JPanels,
[quoted text clipped - 10 lines]
>
:-) Great! Thanks very much.
JH