Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
org.jdesktop.layout.LayoutStyle
public class LayoutStyle
extends java.lang.Object
RELATED
).
This class is primarily useful for JREs prior to 1.6. In 1.6 API for this
was added to Swing. When run on a JRE of 1.6 or greater this will call into
the appropriate methods in Swing.
Field Summary | |
static int |
|
static int |
|
static int |
|
Method Summary | |
int |
|
int |
|
static LayoutStyle |
|
static void |
|
public static final int INDENT
Possible argument to getPreferredGap. Used to indicate the distance to indent a component is being requested. To visually indicate a set of related components they will often times be horizontally indented, theINDENT
constant for this. For example, to indent a check box relative to a label use this constant togetPreferredGap
.
- Field Value:
- 3
public static final int RELATED
Possible argument to getPreferredGap. Used to indicate the two componets are grouped together.
- Field Value:
- 0
public static final int UNRELATED
Possible argument to getPreferredGap. Used to indicate the two componets are not grouped together.
- Field Value:
- 1
public int getContainerGap(JComponent component, int position, Container parent)
Returns the amount of space to position a component inside its parent.
- Parameters:
component
- theComponent
being positionedposition
- the positioncomponent
is being placed relative to its parent; one ofSwingConstants.NORTH
,SwingConstants.SOUTH
,SwingConstants.EAST
orSwingConstants.WEST
parent
- the parent ofcomponent
; this may differ from the actual parent and may be null
- Returns:
- the amount of space to place between the component and specified edge
public int getPreferredGap(JComponent component1, JComponent component2, int type, int position, Container parent)
Returns the amount of space to use between two components. The return value indicates the distance to placecomponent2
relative tocomponent1
. For example, the following returns the amount of space to place betweencomponent2
andcomponent1
whencomponent2
is placed vertically abovecomponent1
:int gap = getPreferredGap(component1, component2, LayoutStyle.RELATED, SwingConstants.NORTH, parent);Thetype
parameter indicates the type of gap being requested. It can be one of the following values:It's important to note that some look and feels may not distinguish between
RELATED
If the two components will be contained in the same parent and are showing similar logically related items, use RELATED
.UNRELATED
If the two components will be contained in the same parent but show logically unrelated items use UNRELATED
.INDENT
Used to obtain the preferred distance to indent a component relative to another. For example, if you want to horizontally indent a JCheckBox relative to a JLabel use INDENT
. This is only useful for the horizontal axis.RELATED
andUNRELATED
. The return value is not intended to take into account the current size and position ofcomponent2
orcomponent1
. The return value may take into consideration various properties of the components. For example, the space may vary based on font size, or the preferred size of the component.
- Parameters:
component1
- theJComponent
component2
is being placed relative tocomponent2
- theJComponent
being placedtype
- how the two components are being placedposition
- the positioncomponent2
is being placed relative tocomponent1
; one ofSwingConstants.NORTH
,SwingConstants.SOUTH
,SwingConstants.EAST
orSwingConstants.WEST
parent
- the parent ofcomponent2
; this may differ from the actual parent and may be null
- Returns:
- the amount of space to place between the two components
public static LayoutStyle getSharedInstance()
Factory methods for obtaining the currentLayoutStyle
object appropriate for the current look and feel.
- Returns:
- the current LayoutStyle instance
public static void setSharedInstance(LayoutStyle layoutStyle)
Sets the LayoutStyle instance to use for this look and feel. You generally don't need to invoke this, instead use the getter which will return the LayoutStyle appropriate for the current look and feel.
- Parameters:
layoutStyle
- the LayoutStyle to use; a value of null indicates the default should be used