I have a series of components underneath each other in a JPanel set as a GridLayout.
I need to temporarily hide the components but setVisible(false)
doesn\'t cu
try to use BoxLayout with component alignment. For example:
JPanel innerPane = new JPanel();
BoxLayout innerPaneLayout = new BoxLayout(innerPane,BoxLayout.Y_AXIS);
innerPane.setLayout(innerPaneLayout);
for (int i = 0; i < 30; i++)
{
JPane newPane = getPane();
innerPane.add(newPane);
newPane.setAlignmentY(Component.TOP_ALIGNMENT);
}
for (int i = 0; i < 30; i++)
{
if (i%2==0)
innerPane.getComponent(i).setVisible(false);
}