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 タイプの Look & Feel の違いを区別できない場合もあります。
戻り値では、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, 2013, Oracle and/or its affiliates. All rights reserved.