- java.lang.Object
 -  
      
- javax.swing.LayoutStyle
 
 
-  
       
public abstract class LayoutStyle extends Object
LayoutStyle提供有关如何定位组件的信息。 该类主要用于可视化工具和布局管理器。 大多数开发人员不需要使用此类。您通常不会设置或创建
LayoutStyle。 而是使用静态方法getInstance来获取当前实例。- 从以下版本开始:
 - 1.6
 
 
-  
        
       
-  
             
嵌套类汇总
嵌套类 变量和类型 类 描述 static classLayoutStyle.ComponentPlacementComponentPlacement是两个组件相对于彼此放置的可能方式的枚举。 
-  
             
构造方法摘要
构造方法 构造器 描述 LayoutStyle()创建一个新的LayoutStyle。 
-  
             
方法摘要
所有方法 静态方法 实例方法 抽象方法 具体的方法 变量和类型 方法 描述 abstract intgetContainerGap(JComponent component, int position, Container parent)返回组件与其父级的指定边之间放置的空间量。static LayoutStylegetInstance()返回LayoutStyle的共享实例。abstract intgetPreferredGap(JComponent component1, JComponent component2, LayoutStyle.ComponentPlacement type, int position, Container parent)返回两个组件之间要使用的空间量。static voidsetInstance(LayoutStyle style)设置共享实例LayoutStyle。 
 -  
             
 
-  
        
       
-  
             
方法详细信息
-  
setInstance
public static void setInstance(LayoutStyle style)
设置共享实例LayoutStyle。 指定null在使用效果LayoutStyle从目前LookAndFeel。- 参数
 -  
              
style-LayoutStyle,或null - 另请参见:
 -  
              
getInstance() 
 
-  
getInstance
public static LayoutStyle getInstance()
返回LayoutStyle的共享实例。 如果未在setInstance指定实例,LayoutStyle从当前的LookAndFeel返回LookAndFeel。- 结果
 - 
               共享实例 
              
LayoutStyle - 另请参见:
 -  
              
LookAndFeel.getLayoutStyle() 
 
-  
getPreferredGap
public abstract int getPreferredGap(JComponent component1, JComponent component2, LayoutStyle.ComponentPlacement type, int position, Container parent)
返回两个组件之间要使用的空间量。 返回值表示的距离放置component2相对component1。 例如,下面的返回的空间量之间放置component2和component1当component2上面垂直放置component1:int gap = getPreferredGap(component1, component2, ComponentPlacement.RELATED, SwingConstants.NORTH, parent);type参数指示两个组件之间的关系。 如果两个组件将包含在同一父组件中并显示类似的逻辑相关项,请使用RELATED。 如果两个组件将包含在同一父组件中但显示逻辑上不相关的项目,请使用UNRELATED。 一些外观可能无法区分RELATED和UNRELATED类型。返回值无意考虑
component2或component1的当前大小和位置。 返回值可以考虑组件的各种属性。 例如,空间可能会根据字体大小或组件的首选大小而有所不同。- 参数
 -  
              
component1-JComponentcomponent2正在相对于 -  
              
component2- 正在JComponent -  
              
position- 第component2相对于component1; 之一SwingConstants.NORTH,SwingConstants.SOUTH,SwingConstants.EAST或SwingConstants.WEST -  
              
type- 两个组件的放置方式 -  
              
parent-的父component2; 这可能与实际的父母不同,可能是null - 结果
 - 两个组件之间放置的空间量
 - 异常
 -  
              
NullPointerException-如果component1,component2或type为null -  
              
IllegalArgumentException-如果position不是一个SwingConstants.NORTH,SwingConstants.SOUTH,SwingConstants.EAST或SwingConstants.WEST - 从以下版本开始:
 - 1.6
 - 另请参见:
 -  
              
LookAndFeel.getLayoutStyle() 
 
-  
getContainerGap
public abstract int getContainerGap(JComponent component, int position, Container parent)
返回组件与其父级的指定边之间放置的空间量。- 参数
 -  
              
component-JComponent被定位 -  
              
position-位置component被放置相对于其父;SwingConstants.NORTHSwingConstants.SOUTH,SwingConstants.EAST或SwingConstants.WEST -  
              
parent-的父component; 这可能与实际的父母不同,可能是null - 结果
 - 在组件和指定边之间放置的空间量
 - 异常
 -  
              
IllegalArgumentException-如果position不是一个SwingConstants.NORTH,SwingConstants.SOUTH,SwingConstants.EAST或SwingConstants.WEST 
 
 -  
 
 -