I have a GUI, which is based on Swing’s JPanelthat uses BorderLayout.In the north panel i have added a new JPanel which uses FlowLayout and contains two textField and other components.
When I change the text of textField and invisible some componets inside this panel, this textField keeps resizing. How can I avoid this? I would like the textField to keep the same size whatever happens. I’ve tried setSize, setPreferredSize, setMinimumSize with no success.
txtSource = new WebTextField(source);
txtSource.setMaximumSize(new Dimension(30,20));
txtSource.setMinimumSize(new Dimension(20, 20));
txtSource.setEditable(false);
txtDestination = new WebTextField(destination);
txtDestination.setMaximumSize(new Dimension(30,20));
txtDestination.setMinimumSize(new Dimension(20, 20));
before:

after:

you can’t do this like what you want, some
LayoutManagersignore forsetXxxSize, but you can use f.e.BoxLayoutthat accepts forsetXxxSize