tags:

views:

41

answers:

1

I'm having this strange issue with Swing. I have a main JPanel to which I am adding a JTabbedPane. Inside of this JTabbedPane I am adding another panel:

myTabbedPane.add(innerPanel, "Title", 0);
outerPanel.add(myTabbedPane);

Now, I no longer want myTabbedPane to be JTabbedPane, I want it to be a JPanel. When I change its type (and remove the extra params from its add() method), nothing within the outerPanel is visible anymore. (I am using setBounds() and I set the layouts to null).

Why does it work when using a tabbed pane but suddenly stop when switching to a JPanel? I know that this can be done differently (such as adding the innerPanel directly to the outerPanel), but please don't just tell me to do it differently. I'd just like to know why it suddenly doesn't work when using a JPanel instead. Is there an issue with adding a JPanel to a JPanel? Thanks!

+3  A: 

Stop using null layout. Use BorderLayout and then use add inner panel to the center. Tabbed pane used it own layered layout - that is why it worked before.

eugener