JPanel superclass doesn't add the components of its subclasses..
- by Acryl
Well, I use a JFrame that adds two JPanels. Those JPanels are superclasses, because I find it easier to separate different areas of the GUI into different classes. But here's the problem:
I add the (superclass) JPanel to the JFrame
I set the layout of the superclass JPanel to new BorderLayout();
I add components in the subclasses, like this:
JPanel panel = new JPanel();
panel.setLayout(new GridLayout(2,1));
panel.add(new
JLabel("Label:");
panel.add(new JTextField();
add(panel,
BorderLayout.NORTH);
But it doesn't show. What do I do wrong?
I've tried it without an additional JPanel in the subclasses, but it doesn't work either.
I use jdk 1.6