How to make subpanels inside my main panel, where are they when I set one of the subpanels to invisible?
What do I see:
[ (Panel1) (Panel2) (Panel3) (Panel4) ]
When I do panel3.setVisible(false) , it looks like this:
[ (Panel1) (Panel2) (Panel4) ]
I would like it to look like this:
[ (Panel1) (Panel2) (Panel4) ]
I am using GridBagLayout and my mainPanel application looks like this:
final JPanel panel = new JPanel(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints();
and I add a new panel, for example:
final JTextField valueTextField = new JTextField(); valueTextField.setPreferredSize(new Dimension(80, 25)); valueTextField.setName("Value"); c.gridx =0; panel.add(valueTextField, c);
I will provide more code if necessary, and I don't care which layout I use until it gets me what I want.
source share