what's the difference between DEFAULT_SIZE and PREFERRED_SIZE?

Posted by CD1 on Stack Overflow See other posts from Stack Overflow or by CD1
Published on 2010-04-01T20:21:32Z Indexed on 2010/04/01 20:23 UTC
Read the original article Hit count: 185

Filed under:
|
|
|

hi,

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 JTextFields 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.

© Stack Overflow or respective owner

Related posts about java

Related posts about swing