| Author |
setPreferredSize() vs GridBagConstraints.fill ?
|
achana chan
Ranch Hand
Joined: Jul 29, 2002
Posts: 277
|
|
Hi all. In my applets, I found that for my components e.g. JTextField, GridBagConstraints.fill = GridBagConstraints.HORIZONTAL would take precedence over component.setPreferredSize(new Dimension(75,17)). In practice, this renders setPreferredSize spurious in a GridBagLayout. Is this your understanding on how it works, that one either uses fill or setPreferredSize ? TIA :-)
|
humanum errare est.
|
 |
achana chan
Ranch Hand
Joined: Jul 29, 2002
Posts: 277
|
|
I think I've answered my own question on this one. Better stick with GridBagLayout paramaters, its much simpler that way. On the other hand, if I use them with setPreferredWidth, I achieve some amazing results in terms of granularity. The flip side is its complexity. It seems to interact with GridBagLayout's allocation of column width. Has anyone tried something like that?
|
 |
Jose Botella
Ranch Hand
Joined: Jul 03, 2001
Posts: 2120
|
|
Hi I have only found setPrerredWidth on TableColumn. Do you mean that one?
|
SCJP2. Please Indent your code using UBB Code
|
 |
achana chan
Ranch Hand
Joined: Jul 29, 2002
Posts: 277
|
|
No, I am using jKomponent.setPreferredWidth(new Dimension(int x, int y)) on JTextFields in a GridBagLayout using only GridBag components such as gridx and gridy. I am happy with it to the extent that it also allows me to fit 2 components into one "cell" , bound by the same gridx and gridy, like this:
|
 |
 |
|
|
subject: setPreferredSize() vs GridBagConstraints.fill ?
|
|
|