I have a JPanel (firstPanel) which is embedded into an other JPanel (secondPanel). I want to create a JTabbedPane with two tabs: one for the firstPanel and one for the secondPanel.
However, when I switch to secondPanel, the embedded firstPanel won't show up.
public class Application extends JFrame
setMinimumSize(new Dimension(300, 300));
JPanel firstPanel = new JPanel();
JPanel secondPanel = new JPanel();
// JPanel thirdPanel = new JPanel();
// thirdPanel.add(new JLabel("third"));
JTabbedPane mainPanel = new JTabbedPane();
public static void main(String args)
Application app = new Application();
This is because you are trying to add a single panel to two different parents, one being your
secondPanel, and the other being your tab. You can't do that.
Can I ask why you think you want to do this? There is probably a better solution out there for you.