Question

When I start my program I have 6 panels. Then I have some radio buttons and depending on the choice some panels hide. In this example I want to hide all panels except 1 and 2. When I click the radio button instead of hiding the rest of the panels and leave the first 2 panels in the current position, it moves them.

private void MonocButtonItemStateChanged(java.awt.event.ItemEvent evt) {                                             
    Panel3.setVisible(false);
    Panel4.setVisible(false);
    Panel5.setVisible(false);
    Panel6.setVisible(false);
}                                      

enter image description here

Was it helpful?

Solution

Propably the panel that contains the show/hide panels has FlowLayout manager. When components get invisible the container lays out from scratch the components again.

To get around with this you can use an AbsoluteLayout or make the panels invisible in a diferent way so you cannot see them but they are occuping space.

OTHER TIPS

Looks like switching to Absolute Layout fixed the problem! Solved!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top