Reusing the same JPanel in Java swing
I have two JPanels that need to add a JPanel, but only the last added JPanel shows the JPanel. As shown below:
holderPanel1.add(dataPanel);
holderPanel2.add(dataPanel);
only holderPanel2 shows dataPanel, but holderPanel1 doesn't show.
+3
sutoL
source
to share
1 answer
UI components (like JPanel) are the main view of things you see on the screen (location, parent, subcomponents, etc.), so each panel you see on screen should have a separate underline view, so you cannot add a panel to two different panels, you need to create two separate panels.
+6
MByD
source
to share