Home » openjdk-7 » javax » swing » [javadoc | source]
javax.swing
abstract public class: LayoutStyle [javadoc | source]
java.lang.Object
   javax.swing.LayoutStyle

Direct Known Subclasses:
    DefaultLayoutStyle, MetalLayoutStyle

LayoutStyle provides 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 method getInstance to obtain the current instance.

Nested Class Summary:
public enum class  LayoutStyle.ComponentPlacement  ComponentPlacement is an enumeration of the possible ways two components can be placed relative to each other. ComponentPlacement is used by the LayoutStyle method getPreferredGap. Refer to LayoutStyle for more information. 
Constructor:
 public LayoutStyle() 
Method from javax.swing.LayoutStyle Summary:
getContainerGap,   getInstance,   getPreferredGap,   setInstance
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from javax.swing.LayoutStyle Detail:
 abstract public int getContainerGap(JComponent component,
    int position,
    Container parent)
    Returns the amount of space to place between the component and specified edge of its parent.
 public static 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.
 abstract public int getPreferredGap(JComponent component1,
    JComponent component2,
    ComponentPlacement type,
    int position,
    Container parent)
    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.

 public static  void setInstance(LayoutStyle style) 
    Sets the shared instance of LayoutStyle. Specifying null results in using the LayoutStyle from the current LookAndFeel.