I am quite new to Java and am trying to set the visible property to false for all JPanels on my JFrame (frame.)
When I execute the following, It returns null to console:
public void mouseClicked(MouseEvent e){
for (Component c : frame.getComponents()) {
System.out.println(c.getName());
if (c instanceof JPanel) {
((JPanel)c).setVisible(false);
}
}
panelDispatch.setVisible(true);
panelDispatch.requestFocus();
}
What I want it to do is set all the panels visibility to false then set the selected panels visibility to true. 3 JPanels are added to frame.
What am I doing wrong here?
Any help would be greatly appreciated.