public abstract class LayoutStyle extends Object
LayoutStyleは、コンポーネントの配置に関する情報を提供します。 このクラスは、主にビジュアル・ツールとレイアウト・マネージャで使用されます。 ほとんどの場合、開発者がこのクラスを使用する必要はありません。
通常、LayoutStyleの設定や作成は行いません。 代わりに、staticメソッドgetInstanceを使って現在のインスタンスを取得します。
| 修飾子と型 | クラス | 説明 |
|---|---|---|
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の共有インスタンスを設定します。 |
public LayoutStyle()
LayoutStyleを作成します。 通常、LayoutStyleは作成しません。 代わりに、getInstanceメソッドを使って現在のLayoutStyleを取得します。 public static void setInstance(LayoutStyle style)
LayoutStyleの共有インスタンスを設定します。 nullを指定すると、現在のLookAndFeelのLayoutStyleが使用されます。 style - LayoutStyle、またはnullgetInstance()public static LayoutStyle getInstance()
LayoutStyleの共有インスタンスを返します。 setInstanceでインスタンスが指定されていない場合は、現在のLookAndFeelのLayoutStyleが返されます。 LayoutStyleの共有インスタンスLookAndFeel.getLayoutStyle()public abstract int getPreferredGap(JComponent component1, JComponent component2, LayoutStyle.ComponentPlacement type, int position, Container parent)
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を配置するとき基準にするJComponentcomponent2 - 配置されるJComponentposition - component1を基準としたcomponent2の配置位置。SwingConstants.NORTH、SwingConstants.SOUTH、SwingConstants.EAST、またはSwingConstants.WESTtype - 2つのコンポーネントの配置方法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 - 配置されるJComponentposition - 親を基準としたcomponentの配置位置。SwingConstants.NORTH、SwingConstants.SOUTH、SwingConstants.EAST、またはSwingConstants.WESTparent - componentの親。実際の親とは異なる可能性がある。また、nullの可能性もあるIllegalArgumentException - positionがSwingConstants.NORTH、SwingConstants.SOUTH、SwingConstants.EASTまたはSwingConstants.WESTのいずれでもない場合 バグまたは機能を送信
詳細なAPIリファレンスおよび開発者ドキュメントについては、Java SEのドキュメントを参照してください。 そのドキュメントには、概念的な概要、用語の定義、回避方法、有効なコード例などの、開発者を対象にしたより詳細な説明が含まれています。
Copyright © 1993, 2025, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Documentation Redistribution Policyも参照してください。