モジュール java.desktop
パッケージ javax.swing

クラスLayoutStyle

java.lang.Object
javax.swing.LayoutStyle

public abstract class LayoutStyle extends Object
LayoutStyleは、コンポーネントの配置に関する情報を提供します。 このクラスは、主にビジュアル・ツールとレイアウト・マネージャで使用されます。 ほとんどの場合、開発者がこのクラスを使用する必要はありません。

通常、LayoutStyleの設定や作成は行いません。 代わりに、staticメソッドgetInstanceを使って現在のインスタンスを取得します。

導入されたバージョン:
1.6
  • ネストされたクラスのサマリー

    ネストされたクラス
    修飾子と型
    クラス
    説明
    static enum 
    ComponentPlacementは、2つのコンポーネントを相互に関連付けて配置する場合に使用できる方法の列挙です。
  • コンストラクタのサマリー

    コンストラクタ
    コンストラクタ
    説明
    新しいLayoutStyleを作成します。
  • メソッドのサマリー

    修飾子と型
    メソッド
    説明
    abstract int
    getContainerGap(JComponent component, int position, Container parent)
    コンポーネントからその親の指定された端までのスペースの量を返します。
    LayoutStyleの共有インスタンスを返します。
    abstract int
    getPreferredGap(JComponent component1, JComponent component2, LayoutStyle.ComponentPlacement type, int position, Container parent)
    2つのコンポーネント間のスペースの量を返します。
    static void
    LayoutStyleの共有インスタンスを設定します。

    クラス java.lang.Objectで宣言されたメソッド

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • コンストラクタの詳細

    • LayoutStyle

      public LayoutStyle()
      新しいLayoutStyleを作成します。 通常、LayoutStyleは作成しません。 代わりに、getInstanceメソッドを使って現在のLayoutStyleを取得します。
  • メソッドの詳細

    • setInstance

      public static void setInstance(LayoutStyle style)
      LayoutStyleの共有インスタンスを設定します。 nullを指定すると、現在のLookAndFeelLayoutStyleが使用されます。
      パラメータ:
      style - LayoutStyle、またはnull
      関連項目:
    • getInstance

      public static LayoutStyle getInstance()
      LayoutStyleの共有インスタンスを返します。 setInstanceでインスタンスが指定されていない場合は、現在のLookAndFeelLayoutStyleが返されます。
      戻り値:
      LayoutStyleの共有インスタンス
      関連項目:
    • getPreferredGap

      public abstract int getPreferredGap(JComponent component1, JComponent component2, LayoutStyle.ComponentPlacement type, int position, Container parent)
      2つのコンポーネント間のスペースの量を返します。 戻り値は、component1を基準としたcomponent2の配置距離を表します。 たとえば、次のコードは、component2component1の上方に配置するときのcomponent2component1の間の距離を返します。
         int gap = getPreferredGap(component1, component2,
                                   ComponentPlacement.RELATED,
                                   SwingConstants.NORTH, parent);
       
      typeパラメータは、2つのコンポーネントの関係を示します。 2つのコンポーネントが同じ親を持ち、論理的に関連性のあるよく似た項目を表示している場合、RELATEDを使用します。 2つのコンポーネントの親が同じであっても、論理的に関連性のない項目を表示している場合は、UNRELATEDを使用します。 RELATEDタイプとUNRELATEDタイプのルック・アンド・フィールの違いを区別できない場合もあります。

      戻り値では、component2またはcomponent1の現在のサイズと位置が考慮されません。 戻り値で、コンポーネントのさまざまなプロパティが考慮されることがあります。 たとえば、スペースは、フォント・サイズやコンポーネントの適切なサイズによって異なる可能性があります。

      パラメータ:
      component1 - component2を配置するとき基準にするJComponent
      component2 - 配置されるJComponent
      position - component1を基準としたcomponent2の配置位置。SwingConstants.NORTHSwingConstants.SOUTHSwingConstants.EAST、またはSwingConstants.WEST
      type - 2つのコンポーネントの配置方法
      parent - component2の親。実際の親とは異なる可能性がある。また、nullの可能性もある
      戻り値:
      2つのコンポーネント間のスペースの量
      例外:
      NullPointerException - component1component2、またはtypenullの場合
      IllegalArgumentException - positionSwingConstants.NORTHSwingConstants.SOUTHSwingConstants.EASTまたはSwingConstants.WESTのいずれでもない場合
      導入されたバージョン:
      1.6
      関連項目:
    • getContainerGap

      public abstract int getContainerGap(JComponent component, int position, Container parent)
      コンポーネントからその親の指定された端までのスペースの量を返します。
      パラメータ:
      component - 配置されるJComponent
      position - 親を基準としたcomponentの配置位置。SwingConstants.NORTHSwingConstants.SOUTHSwingConstants.EAST、またはSwingConstants.WEST
      parent - componentの親。実際の親とは異なる可能性がある。また、nullの可能性もある
      戻り値:
      コンポーネントから指定の端までのスペースの量
      例外:
      IllegalArgumentException - positionSwingConstants.NORTHSwingConstants.SOUTHSwingConstants.EASTまたはSwingConstants.WESTのいずれでもない場合