public abstract class LayoutStyle extends Object
LayoutStyle提供了有关如何定位组件的信息。 
       这个类主要用于可视化工具和布局管理器。 
       大多数开发人员不需要使用这个类。 
        您通常不设置或创建LayoutStyle 。 而是使用静态方法getInstance来获取当前实例。 
| Modifier and Type | Class and Description | 
|---|---|
| static class  | LayoutStyle.ComponentPlacementComponentPlacement是可以相对于彼此放置两个组件的可能方式的列举。 | 
| Constructor and Description | 
|---|
| LayoutStyle()
              创建一个新的 
              LayoutStyle。 | 
| Modifier and Type | Method and Description | 
|---|---|
| abstract int | getContainerGap(JComponent component, int position, Container parent)
              返回要放置在组件与其父项的指定边缘之间的空间量。 
             | 
| static LayoutStyle | getInstance()
              返回共享实例 
              LayoutStyle。 | 
| abstract int | getPreferredGap(JComponent component1, JComponent component2, LayoutStyle.ComponentPlacement type, int position, Container parent)
              返回两个组件之间使用的空间量。 
             | 
| static void | setInstance(LayoutStyle style)
              设置共享实例 
              LayoutStyle。 | 
public LayoutStyle()
LayoutStyle 。 
           你通常不会创建一个LayoutStyle 。 
           而是使用方法getInstance获取当前的LayoutStyle 。 
          public static void setInstance(LayoutStyle style)
LayoutStyle 。 
           指定null结果是使用LayoutStyle从目前的LookAndFeel 。 
          style - 
            LayoutStyle或 
            null 
           getInstance() 
           public static LayoutStyle getInstance()
LayoutStyle 。 
           如果实例尚未在指定的setInstance ,这将返回LayoutStyle从目前LookAndFeel 。 
          LayoutStyle 
           LookAndFeel.getLayoutStyle() 
           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 - 
            JComponent 
            component2是相对于 
           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 
           LookAndFeel.getLayoutStyle() 
           public abstract int getContainerGap(JComponent component, int position, Container parent)
component - 
            JComponent定位 
           position - 相对于其父母放置位置component ; 
            之一SwingConstants.NORTH , SwingConstants.SOUTH , SwingConstants.EAST或SwingConstants.WEST 
           parent - 父母component ; 
            这可能与实际的父母有所不同,可能是null 
           IllegalArgumentException -如果 
            position不是一个 
            SwingConstants.NORTH , 
            SwingConstants.SOUTH , 
            SwingConstants.EAST或 
            SwingConstants.WEST 
            Submit a bug or feature 
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
 Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.