[Y-devel] Widget size negotiation
Jason Cwik jason-y at cwik.org
Wed Feb 25 16:25:40 GMT 2004
For those of you who are working on size negotiation/layouts, you might
want to peruse how Java does it.
Each container has a Layout Manager object associated with it. The
Layout is responsible for placing and sizing widgets. The LayoutManager
class is abstract.
https://java.sun.com/j2se/1.4.2/docs/api/java/awt/LayoutManager.html
Each widget can specify it's minimum/maximum/preferred sizes.
https://java.sun.com/j2se/1.4.2/docs/api/java/awt/Component.html#getPreferredSize()
Then there are concrete subclasses of LayoutManager. One of the most
useful is GridBagLayout. This allows many of the things that people on
this list have been discussing. Each widget gets an (X,Y) in the grid,
insets to pad the cell, cell spanning, and horizontal and vertical
'weights'. When the GridBagLayout performs its layout, it tries to give
everyone their preferred size, and then any extra space is distributed
to widgets with the highest weights.
https://java.sun.com/j2se/1.4.2/docs/api/java/awt/GridBagLayout.html
Of course, I'm not saying that we duplicate how Java does it, but Java's
layouts do work well, and resize well. So, take a look at Java before
you finalize your design.
More information about the Y-devel mailing list
2026 © www.Y-Windows.Org - All Rights Reserved