I'm using Swing GroupLayout and I'm confused about the values GroupLayout.DEFAULT_SIZE
and GroupLayout.PREFERRED_SIZE
. I never know when to use each one of them in methods like GroupLayout.addComponent(Component, int, int, int)
.
suppose I have this code:
GroupLayout l = ...;
l.setHorizontalGroup(l.createSequentialGroup()
.addComponent(tf1)
.addComponent(tf2));
l.setVerticalGroup(l.createParallelGroup()
.addComponent(tf1)
.addComponent(tf2));
there are two JTextField
s on a single line laid out with GroupLayout
(one sequential group horizontally and one parallel group vertically). if I resize the window now, both components get the available space (50% each). but I want only the first text field to grow/shrink horizontally and only the second text field to grow/shrink vertically. what values of min, pref and max should I use to accomplish that? I know I can just try it and see what combination works but I'd like to know the reasoning behind this problem.