APIdia Launch Partner
Top Description Fields Constructors Methods
sun.swing

public Class DefaultLayoutStyle

extends LayoutStyle
Class Inheritance
Known Direct Subclasses
com.sun.java.swing.plaf.gtk.GTKLookAndFeel.GnomeLayoutStyle, javax.swing.plaf.metal.MetalLookAndFeel.MetalLayoutStyle
Imports
java.awt.Container, .Insets, javax.swing.*, .LayoutStyle.ComponentPlacement, javax.swing.border.Border, javax.swing.plaf.UIResource

An implementation of LayoutStyle that returns 6 for related components, otherwise 12. This class also provides helper methods for subclasses.

Field Summary

Modifier and TypeField and Description
private static final DefaultLayoutStyle

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private void
checkPosition(int position)

protected int
flipDirection(int position)

protected int

Returns:

offset - border/margin around the component.
getButtonGap
(JComponent
First component
source
,
JComponent
Second component
target
,
int
Position doing layout along.
position
,
int
Ideal offset, not including border/margin
offset
)

For some look and feels check boxes and radio buttons typically don't paint the border, yet they have padding for a border.

protected int

Returns:

offset - border/margin around the component.
getButtonGap
(JComponent
Component
source
,
int
Position doing layout along.
position
,
int
Ideal offset, not including border/margin
offset
)

For some look and feels check boxes and radio buttons typically don't paint the border, yet they have padding for a border.

public int
getButtonGap(JComponent c, int position)

If c is a check box or radio button, and the border is not painted this returns the inset along the specified axis.

public int
getContainerGap(JComponent component, int position, Container parent)

Implements abstract javax.swing.LayoutStyle.getContainerGap.

Returns the amount of space to place between the component and specified edge of its parent.

private Icon
protected int
getIndent(JComponent c, int position)

Returns the amount to indent the specified component if it's a JCheckBox or JRadioButton.

private int
getInset(JComponent c, int position)

private int
getInset(Insets insets, int position)

public static LayoutStyle
getInstance()

Hides javax.swing.LayoutStyle.getInstance.

Returns the shared instance of LayoutStyle.

public int
getPreferredGap(JComponent component1, JComponent component2, LayoutStyle.ComponentPlacement type, int position, Container parent)

Implements abstract javax.swing.LayoutStyle.getPreferredGap.

Returns the amount of space to use between two components.

protected boolean
isLabelAndNonlabel(JComponent c1, JComponent c2, int position)

Returns true if the classes identify a JLabel and a non-JLabel along the horizontal axis.

private boolean
isLeftAligned(AbstractButton button, int position)

private boolean
isRightAligned(AbstractButton button, int position)

Inherited from javax.swing.LayoutStyle:
setInstance

Field Detail

INSTANCEback to summary
private static final DefaultLayoutStyle INSTANCE

Constructor Detail

DefaultLayoutStyleback to summary
public DefaultLayoutStyle()

Method Detail

checkPositionback to summary
private void checkPosition(int position)
flipDirectionback to summary
protected int flipDirection(int position)
getButtonGapback to summary
protected int getButtonGap(JComponent source, JComponent target, int position, int offset)

For some look and feels check boxes and radio buttons typically don't paint the border, yet they have padding for a border. Look and feel guidelines generally don't include this space. Use this method to subtract this space from the specified components.

Parameters
source:JComponent

First component

target:JComponent

Second component

position:int

Position doing layout along.

offset:int

Ideal offset, not including border/margin

Returns:int

offset - border/margin around the component.

getButtonGapback to summary
protected int getButtonGap(JComponent source, int position, int offset)

For some look and feels check boxes and radio buttons typically don't paint the border, yet they have padding for a border. Look and feel guidelines generally don't include this space. Use this method to subtract this space from the specified components.

Parameters
source:JComponent

Component

position:int

Position doing layout along.

offset:int

Ideal offset, not including border/margin

Returns:int

offset - border/margin around the component.

getButtonGapback to summary
public int getButtonGap(JComponent c, int position)

If c is a check box or radio button, and the border is not painted this returns the inset along the specified axis.

getContainerGapback to summary
public int getContainerGap(JComponent component, int position, Container parent)

Implements abstract javax.swing.LayoutStyle.getContainerGap.

Doc from javax.swing.LayoutStyle.getContainerGap.

Returns the amount of space to place between the component and specified edge of its parent.

Annotations
@Override
getIconback to summary
private Icon getIcon(AbstractButton button)
getIndentback to summary
protected int getIndent(JComponent c, int position)

Returns the amount to indent the specified component if it's a JCheckBox or JRadioButton. If the component is not a JCheckBox or JRadioButton, 0 will be returned.

getInsetback to summary
private int getInset(JComponent c, int position)
getInsetback to summary
private int getInset(Insets insets, int position)
getInstanceback to summary
public static LayoutStyle getInstance()

Hides javax.swing.LayoutStyle.getInstance.

Doc from javax.swing.LayoutStyle.getInstance.

Returns the shared instance of LayoutStyle. If an instance has not been specified in setInstance, this will return the LayoutStyle from the current LookAndFeel.

getPreferredGapback to summary
public int getPreferredGap(JComponent component1, JComponent component2, LayoutStyle.ComponentPlacement type, int position, Container parent)

Implements abstract javax.swing.LayoutStyle.getPreferredGap.

Doc from javax.swing.LayoutStyle.getPreferredGap.

Returns the amount of space to use between two components. The return value indicates the distance to place component2 relative to component1. For example, the following returns the amount of space to place between component2 and component1 when component2 is placed vertically above component1:

  int gap = getPreferredGap(component1, component2,
                            ComponentPlacement.RELATED,
                            SwingConstants.NORTH, parent);
The type parameter indicates the relation between the two components. If the two components will be contained in the same parent and are showing similar logically related items, use RELATED. If the two components will be contained in the same parent but show logically unrelated items use UNRELATED. Some look and feels may not distinguish between the RELATED and UNRELATED types.

The return value is not intended to take into account the current size and position of component2 or component1. 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.

Annotations
@Override
isLabelAndNonlabelback to summary
protected boolean isLabelAndNonlabel(JComponent c1, JComponent c2, int position)

Returns true if the classes identify a JLabel and a non-JLabel along the horizontal axis.

isLeftAlignedback to summary
private boolean isLeftAligned(AbstractButton button, int position)
isRightAlignedback to summary
private boolean isRightAligned(AbstractButton button, int position)