I register to a cardPanel object 3 JPanel.
JPanel cardPanel = new JPanel(new CardLayout());
cardPanel.add(viewPerf, "Performances");
cardPanel.add(viewFaults, "Faults");
cardPanel.add(viewGraph, "Throughput Graph");
I would obtain exactly one JPanel.how can I do this operation?
To show a particular component in a
CardLayout, use theCardLayout#show(String)method, passing the name you gave the component when you added it:Alternatively, you can save the layout when you create it:
Edit: To get a reference to the currently visible component, I believe you can do this: