getPreferredHeight takes width as input, where -1 signals "nothing
particular", and vice versa for getPreferredWidth.

Those methods are used for "constrained" preferred size calculations. For example, a wrapping label takes the width constraint into account when calculating a value in getPreferredHeight(int). A constraint of -1 means "unconstrained". getPreferredSize() basically translates to getPreferredWidth(-1), getPreferredHeight(-1).

Can a component not say "Give me whatever space that is available, and
I'll do what I can with what you give me." ?

No - that's not how Pivot (or Swing) layout works. Components can only report the (pixel) size they would like to be - it is up to the layout manager (i.e. the container skin) to determine how/if to respect that preference.

To achieve the layout behavior you describe, you might use a TablePane with a column of width "1*". That means, "give 100% of the available width to this column". Any component in that column will be given that width.


Reply via email to