I am creating a GUI with grid layout. I have added the JTextFields, JButtons and everything to it DIRECTLY. For an example, like this,
JButton b1 = new JButton("Hello"):
JButton b2 = new JButton("Bye");
JTextField t1 = new JTextField(10);
JTextField t2 = new JTextField(10);
GridLayout grid = new GridLayout(2,2,2,2);
JPanel panel = new JPanel();
panel.setLayout(grid);
panel.add(b1);
panel.add(t1);
panel.add(b2);
panel.add(t2);
In here, if the user resizes the window everything appears very large. The only other way I know to prevent these from getting these is adding all of each and everything to seperate JPanel which has FlowLayout. But thats not practical because if there are 20 stuff, there will be 20 JPanels. I tried setting the maximum size, minimum size and all, and they didnt change any. Please help.
not possible with plain GridLayout, because this is basic feature of this Layout Manager
use proper Layout Manager GridBagLayout or todays MigLayout
very simple way is by using SpringLayout