|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public static interface MSBLayout.MutableConstraints
Extends the (read-only) Constraints
interface with methods to modify the
constraints.
Every box in an MSBLayout is associated with a Constraints object that controls the sizing and
placement behaviour of the box. The methods MSBLayout.add(Component, Constraints)
,
Container.add(Component, Object)
, hbox(Constraints)
and vbox(Constraints)
accept Constraints that will be used
for the new box. If you do not use one of these methods, MSBLayout
will use a
ConstraintsFactory
to provide an appropriate Constraints object.
Constraints is a read-only interface. The interface MutableConstraints
extends Constraints with the corresponding methods for setting constraints.
The method MSBLayout.add(Component)
for instance returns an object of type
MutableConstraints that allows you to change the constraints of the box just added.
A simple implementation of this interface is available as the ConstraintsImpl
class.
MSBLayout.ConstraintsImpl
,
MSBLayout.Constraints
Method Summary | |
---|---|
MSBLayout.MutableConstraints |
bottom(int bottomMargin)
Sets the bottom margin and leaves the other margins unchanged. |
MSBLayout.MutableConstraints |
groups(String groups)
Takes a comma-separated list of group names (that must not contain spurious
whitespace) that will replace the list of groups this box is currently part of. |
MSBLayout.MutableConstraints |
groups(String[] groups)
Takes a list of group names that will replace the list of groups this box is
currently part of. |
MSBLayout.MutableConstraints |
halign(float a)
When this box is contained in a box that has excess blank space, the alignment determines where that blank space will be relative to this box. |
MSBLayout.MutableConstraints |
hfill(int fill)
Sets the box's willingness to grow horizontally to fill excess space. 0 means the Box insists on its preferred size. 1 means this Box is willing to grow to its maximum size if required. 2 means the Box is willing to grow beyond its maximum size if there is still too much space after all boxes with willingness == 1 have been grown to their max sizes. |
MSBLayout.MutableConstraints |
hscale(float scale)
A box that is part of a Group with tieWidth() uses the
group's tied minimum, preferred and maximum widths multiplied by this factor. |
MSBLayout.MutableConstraints |
hshrink(int weight)
When boxes are shrunk below their preferred sizes because their container is too small, the weight value determines the relative amount of space this Box will lose. |
MSBLayout.MutableConstraints |
hweight(int weight)
When boxes are grown to fill excess space in the parent container, the weight value determines the relative portion of space this Box will get. |
MSBLayout.MutableConstraints |
left(int leftMargin)
Sets the left margin and leaves the other margins unchanged. |
MSBLayout.MutableConstraints |
margin(Insets insets)
Sets an amount of blank space to be added around the box's content. |
MSBLayout.MutableConstraints |
margin(int top,
int left,
int bottom,
int right)
Sets an amount of blank space to be added around the box's content. |
MSBLayout.MutableConstraints |
padding(Dimension insets)
Sets an amount of space to be added to the box's minimum, preferred and maximum sizes when doing size computations. |
MSBLayout.MutableConstraints |
padding(int width,
int height)
Sets an amount of space to be added to the box's minimum, preferred and maximum sizes when doing size computations. |
MSBLayout.MutableConstraints |
right(int rightMargin)
Sets the right margin and leaves the other margins unchanged. |
MSBLayout.MutableConstraints |
setConstraints(MSBLayout.Constraints orig)
Copies the settings from orig to this MutableConstraints object. |
MSBLayout.MutableConstraints |
top(int topMargin)
Sets the top margin and leaves the other margins unchanged. |
MSBLayout.MutableConstraints |
valign(float a)
When this box is contained in a box that has excess blank space, the alignment determines where that blank space will be relative to this box. |
MSBLayout.MutableConstraints |
vfill(int fill)
Sets the box's willingness to grow vertically to fill excess space. 0 means the Box insists on its preferred size. 1 means this Box is willing to grow to its maximum size if required. 2 means the Box is willing to grow beyond its maximum size if there is still too much space after all boxes with willingness == 1 have been grown to their max sizes. |
MSBLayout.MutableConstraints |
vscale(float scale)
A box that is part of a Group with tieHeight() uses
the group's tied minimum, preferred and maximum heights multiplied by this factor. |
MSBLayout.MutableConstraints |
vshrink(int weight)
When boxes are shrunk below their preferred sizes because their container is too small, the weight value determines the relative amount of space this Box will lose. |
MSBLayout.MutableConstraints |
vweight(int weight)
When boxes are grown to fill excess space in the parent container, the weight value determines the relative portion of space this Box will get. |
Methods inherited from interface de.winterdrache.layout.MSBLayout.Constraints |
---|
bottom, groups, halign, hfill, hscale, hshrink, hweight, left, margin, padding, right, top, valign, vfill, vscale, vshrink, vweight |
Method Detail |
---|
MSBLayout.MutableConstraints groups(String groups)
group
names (that must not contain spurious
whitespace) that will replace the list of groups this box is currently part of. null
may be passed to remove the box from any groups. Note that passing the empty string will NOT
clear the list of groups. The empty string is a legitimate group name.
MSBLayout.Constraints.groups()
,
groups(String[])
MSBLayout.MutableConstraints groups(String[] groups)
group
names that will replace the list of groups this box is
currently part of. null may be passed to remove the box from any groups.
MSBLayout.Constraints.groups()
,
groups(String)
MSBLayout.MutableConstraints margin(Insets insets)
Gap
constants. To set the
margins for the different sides individually, you can use the methods top(int)
,
left(int)
, bottom(int)
and right(int)
.
MSBLayout.Gap
,
margin(int, int, int, int)
,
MSBLayout.Constraints.margin()
,
padding(Dimension)
,
top(int)
,
left(int)
,
bottom(int)
,
right(int)
MSBLayout.MutableConstraints margin(int top, int left, int bottom, int right)
Gap
constants. To set the
margins for the different sides individually, you can use the methods top(int)
,
left(int)
, bottom(int)
and right(int)
.
MSBLayout.Gap
,
margin(Insets)
,
MSBLayout.Constraints.margin()
,
padding(int, int)
,
top(int)
,
left(int)
,
bottom(int)
,
right(int)
MSBLayout.MutableConstraints left(int leftMargin)
Gap
constants.
MSBLayout.Gap
,
margin(Insets)
,
margin(int, int, int, int)
,
padding(int, int)
,
MSBLayout.Constraints.left()
MSBLayout.MutableConstraints right(int rightMargin)
Gap
constants.
MSBLayout.Gap
,
margin(Insets)
,
margin(int, int, int, int)
,
padding(int, int)
,
MSBLayout.Constraints.right()
MSBLayout.MutableConstraints top(int topMargin)
Gap
constants.
MSBLayout.Gap
,
margin(Insets)
,
margin(int, int, int, int)
,
padding(int, int)
,
MSBLayout.Constraints.top()
MSBLayout.MutableConstraints bottom(int bottomMargin)
Gap
constants.
MSBLayout.Gap
,
margin(Insets)
,
margin(int, int, int, int)
,
padding(int, int)
,
MSBLayout.Constraints.bottom()
MSBLayout.MutableConstraints padding(Dimension insets)
Dimension
must be
non-negative.
Note that padding is very different from a margin. A margin is an empty space around a box.
Padding on the other hand grows the box's content. Unlike margins, padding is used rather
infrequently.
padding(int, int)
,
MSBLayout.Constraints.padding()
,
margin(Insets)
MSBLayout.MutableConstraints padding(int width, int height)
padding(Dimension)
,
MSBLayout.Constraints.padding()
,
margin(int, int, int, int)
MSBLayout.MutableConstraints hweight(int weight)
MAX_WEIGHT_SHRINK
and can be set independently for
horizontal (hweight) and vertical space (vweight). ATTENTION! The weight must be greater than
0. This is different from GridBagLayout
where a weight of 0 means that a box will not
grow. If you don't want a box to grow, use hfill(int)
/ vfill(int)
.
hshrink(int)
plays a similar role when shrinking a box below its preferred width.
IllegalArgumentException
- if weight <= 0 or > MAX_WEIGHT_SHRINK
.vweight(int)
,
MSBLayout.Constraints.hweight()
,
hshrink(int)
MSBLayout.MutableConstraints vweight(int weight)
MAX_WEIGHT_SHRINK
and can be set independently for
horizontal (hweight) and vertical space (vweight). ATTENTION! The weight must be greater than
0. This is different from GridBagLayout
where a weight of 0 means that a box will not
grow. If you don't want a box to grow, use hfill(int)
/ vfill(int)
.
vshrink(int)
plays a similar role when shrinking a box below its preferred height.
IllegalArgumentException
- if weight <= 0 or > MAX_WEIGHT_SHRINK
.hweight(int)
,
MSBLayout.Constraints.vweight()
,
vshrink(int)
MSBLayout.MutableConstraints hshrink(int weight)
MAX_WEIGHT_SHRINK
and can be set
independently for horizontal (hshrink) and vertical space (vshrink). hweight(int)
plays a similar role when growing a box larger than its preferred width.
NOTE: When you find that the hshrink value seems to have no effect, this may be due to one of the following reasons:
JTextField
s) are placed next to components with a minimum size (such as
JLabel
s). Even a very large hshrink value will not cause MSBLayout to shrink a
component below its minimum size as long as alternatives exist.
IllegalArgumentException
- if weight <= 0 or > MAX_WEIGHT_SHRINK
.vshrink(int)
,
MSBLayout.Constraints.hshrink()
,
hweight(int)
MSBLayout.MutableConstraints vshrink(int weight)
MAX_WEIGHT_SHRINK
and can be set
independently for horizontal (hshrink) and vertical space (vshrink). vweight(int)
plays a similar role when growing a box larger than its preferred height.
NOTE: When you find that the vshrink value seems to have no effect, this may be due to one of the following reasons:
JTextField
s) are placed next to components with a minimum size (such as
JLabel
s). Even a very large vshrink value will not cause MSBLayout to shrink a
component below its minimum size as long as alternatives exist.
IllegalArgumentException
- if weight <= 0 or > MAX_WEIGHT_SHRINK
.hshrink(int)
,
MSBLayout.Constraints.vshrink()
,
vweight(int)
MSBLayout.MutableConstraints halign(float a)
An alignment < 0 means "justify", i.e. if this box is the first or the last in the container box, it will touch at least one edge of the container, otherwise it will be positioned exactly in the middle between its two sibling boxes. An alignment between 0.0 and 1.0 specifies the percentage of all blank space that is to be placed before this box. E.g an alignment of 0.5 means that 50% of the empty space will be placed before the Box and 50% after it. Note that this will not necessarily result in the Box being in the exact center of the container box, because the presence of sibling boxes will affect its placement, too. Alignments >1.0 mean the same as 1.0.
In no event will alignment cause 2 boxes to overlap. E.g. 2 sibling boxes with alignment 0.5 will not overlap each other. Instead they will form a cluster that is as a whole centered (with respect to the empty space, not necessarily with respect to the parent container). If the alignment of a box is less than the alignment of a sibling box that comes before it, its alignment will be assumed to be the same as the sibling.
The alignment can be set independently for horizontal (halign) and vertical alignment (valign).
MSBLayout.setSingleBoxJustifyBehaviour(float, float, int, int)
controls how the
special case of a single box without siblings is handled when its alignment is "justify".
MSBLayout.Constraints.halign()
,
valign(float)
MSBLayout.MutableConstraints valign(float a)
halign(float)
for a
detailed explanation of alignment.
MSBLayout.Constraints.valign()
,
halign(float)
MSBLayout.MutableConstraints setConstraints(MSBLayout.Constraints orig)
MutableConstraints
object.
MSBLayout.MutableConstraints hfill(int fill)
IllegalArgumentException
- if the number passed is not 0, 1 or 2.vfill(int)
,
MSBLayout.Constraints.hfill()
MSBLayout.MutableConstraints vfill(int fill)
IllegalArgumentException
- if the number passed is not 0, 1 or 2.hfill(int)
,
MSBLayout.Constraints.vfill()
MSBLayout.MutableConstraints hscale(float scale)
Group
with tieWidth()
uses the
group's tied minimum, preferred and maximum widths multiplied by this factor. You would use
this feature when building a grid with same size cells to simulate merged cells.
MSBLayout.Constraints.hscale()
,
vscale(float)
MSBLayout.MutableConstraints vscale(float scale)
Group
with tieHeight()
uses
the group's tied minimum, preferred and maximum heights multiplied by this factor. You would
use this feature when building a grid with same size cells to simulate merged cells.
hscale(float)
,
MSBLayout.Constraints.vscale()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 2010 Matthias S. Benkmann. See LICENSE file for licensing details.
Hosted on