No....usually you would use arithmetic expressions that involve the current size of the frame.
You want the spaces in your design to expand or shrink in proportion
to the size of the frame.
A fixed-sized component is inflexible.
All GUI components have a getSize()
method that
is used to determine the dimensions of the component.
The dimensions may change as a program executes, so this is a useful method.
To determine the current size of a frame, use:
Dimension JFrame.getSize()
Then it can look at the height
and width
fields of
the Dimension
object.
Using this data it can create a rigid area of appropriate size.
If this is too complicated, then use glue.
The glue component is
another invisible component that class Box
creates.
Think of glue as stretchy caulking between components.
It keeps them separated, but expands or shrinks if needed.
To create glue use one of the following:
Box.createHorizontalGlue() Box.createVerticalGlue()