- java.lang.Object
- 
- javax.swing.LayoutStyle
 
- 
 public abstract class LayoutStyle extends Object LayoutStyleprovides information about how to position components. This class is primarily useful for visual tools and layout managers. Most developers will not need to use this class.You typically don't set or create a LayoutStyle. Instead use the static methodgetInstanceto obtain the current instance.- Since:
- 1.6
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classLayoutStyle.ComponentPlacementComponentPlacementis an enumeration of the possible ways two components can be placed relative to each other.
 - 
Constructor SummaryConstructors Constructor Description LayoutStyle()Creates a newLayoutStyle.
 - 
Method SummaryAll Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract intgetContainerGap(JComponent component, int position, Container parent)Returns the amount of space to place between the component and specified edge of its parent.static LayoutStylegetInstance()Returns the shared instance ofLayoutStyle.abstract intgetPreferredGap(JComponent component1, JComponent component2, LayoutStyle.ComponentPlacement type, int position, Container parent)Returns the amount of space to use between two components.static voidsetInstance(LayoutStyle style)Sets the shared instance ofLayoutStyle.
 
- 
- 
- 
Method Detail- 
setInstancepublic static void setInstance(LayoutStyle style) Sets the shared instance ofLayoutStyle. Specifyingnullresults in using theLayoutStylefrom the currentLookAndFeel.- Parameters:
- style- the- LayoutStyle, or- null
- See Also:
- getInstance()
 
 - 
getInstancepublic static LayoutStyle getInstance() Returns the shared instance ofLayoutStyle. If an instance has not been specified insetInstance, this will return theLayoutStylefrom the currentLookAndFeel.- Returns:
- the shared instance of LayoutStyle
- See Also:
- LookAndFeel.getLayoutStyle()
 
 - 
getPreferredGappublic abstract int getPreferredGap(JComponent component1, JComponent component2, LayoutStyle.ComponentPlacement type, int position, Container parent) Returns the amount of space to use between two components. The return value indicates the distance to placecomponent2relative tocomponent1. For example, the following returns the amount of space to place betweencomponent2andcomponent1whencomponent2is placed vertically abovecomponent1:int gap = getPreferredGap(component1, component2, ComponentPlacement.RELATED, SwingConstants.NORTH, parent);Thetypeparameter 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, useRELATED. If the two components will be contained in the same parent but show logically unrelated items useUNRELATED. Some look and feels may not distinguish between theRELATEDandUNRELATEDtypes.The return value is not intended to take into account the current size and position of component2orcomponent1. 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- the- JComponent- component2is being placed relative to
- component2- the- JComponentbeing placed
- position- the position- component2is being placed relative to- component1; one of- SwingConstants.NORTH,- SwingConstants.SOUTH,- SwingConstants.EASTor- SwingConstants.WEST
- type- how the two components are being placed
- parent- the parent of- component2; this may differ from the actual parent and it may be- null
- Returns:
- the amount of space to place between the two components
- Throws:
- NullPointerException- if- component1,- component2or- typeis- null
- IllegalArgumentException- if- positionis not one of- SwingConstants.NORTH,- SwingConstants.SOUTH,- SwingConstants.EASTor- SwingConstants.WEST
- Since:
- 1.6
- See Also:
- LookAndFeel.getLayoutStyle()
 
 - 
getContainerGappublic abstract int getContainerGap(JComponent component, int position, Container parent) Returns the amount of space to place between the component and specified edge of its parent.- Parameters:
- component- the- JComponentbeing positioned
- position- the position- componentis being placed relative to its parent; one of- SwingConstants.NORTH,- SwingConstants.SOUTH,- SwingConstants.EASTor- SwingConstants.WEST
- parent- the parent of- component; this may differ from the actual parent and may be- null
- Returns:
- the amount of space to place between the component and specified edge
- Throws:
- IllegalArgumentException- if- positionis not one of- SwingConstants.NORTH,- SwingConstants.SOUTH,- SwingConstants.EASTor- SwingConstants.WEST
 
 
- 
 
-