- java.lang.Object
-
- javax.swing.LayoutStyle
-
public abstract class LayoutStyle extends Object
LayoutStyle
は、コンポーネントの配置に関する情報を提供します。 このクラスは、主にビジュアル・ツールとレイアウト・マネージャで使用されます。 ほとんどの場合、開発者がこのクラスを使用する必要はありません。通常、
LayoutStyle
の設定や作成は行いません。 代わりに、staticメソッドgetInstance
を使って現在のインスタンスを取得します。- 導入されたバージョン:
- 1.6
-
-
ネストされたクラスのサマリー
ネストされたクラス 修飾子と型 クラス 説明 static class
LayoutStyle.ComponentPlacement
ComponentPlacement
は、2つのコンポーネントを相互に関連付けて配置する場合に使用できる方法の列挙です。
-
コンストラクタのサマリー
コンストラクタ コンストラクタ 説明 LayoutStyle()
新しいLayoutStyle
を作成します。
-
メソッドのサマリー
修飾子と型 メソッド 説明 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)
2つのコンポーネント間のスペースの量を返します。static void
setInstance(LayoutStyle style)
LayoutStyle
の共有インスタンスを設定します。
-
-
-
メソッドの詳細
-
setInstance
public static void setInstance(LayoutStyle style)
LayoutStyle
の共有インスタンスを設定します。null
を指定すると、現在のLookAndFeel
のLayoutStyle
が使用されます。- パラメータ:
style
-LayoutStyle
、またはnull
- 関連項目:
getInstance()
-
getInstance
public static LayoutStyle getInstance()
LayoutStyle
の共有インスタンスを返します。setInstance
でインスタンスが指定されていない場合は、現在のLookAndFeel
のLayoutStyle
が返されます。- 戻り値:
LayoutStyle
の共有インスタンス- 関連項目:
LookAndFeel.getLayoutStyle()
-
getPreferredGap
public abstract int getPreferredGap(JComponent component1, JComponent component2, LayoutStyle.ComponentPlacement type, int position, Container parent)
2つのコンポーネント間のスペースの量を返します。 戻り値は、component1
を基準としたcomponent2
の配置距離を表します。 たとえば、次のコードは、component2
をcomponent1
の上方に配置するときのcomponent2
とcomponent1
の間の距離を返します。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.NORTH
、SwingConstants.SOUTH
、SwingConstants.EAST
、またはSwingConstants.WEST
type
- 2つのコンポーネントの配置方法parent
-component2
の親。実際の親とは異なる可能性がある。また、null
の可能性もある- 戻り値:
- 2つのコンポーネント間のスペースの量
- 例外:
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.NORTH
、SwingConstants.SOUTH
、SwingConstants.EAST
、またはSwingConstants.WEST
parent
-component
の親。実際の親とは異なる可能性がある。また、null
の可能性もある- 戻り値:
- コンポーネントから指定の端までのスペースの量
- 例外:
IllegalArgumentException
-position
がSwingConstants.NORTH
、SwingConstants.SOUTH
、SwingConstants.EAST
またはSwingConstants.WEST
のいずれでもない場合
-
-