JavaTM 2 Platform
Std. Ed. v1.3

javax.swing
クラス Box

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.Box
すべての実装インタフェース:
Accessible, ImageObserver, MenuContainer, Serializable

public class Box
extends Container
implements Accessible

BoxLayout オブジェクトをレイアウトマネージャとして使用する、軽量なコンテナです。Box は、BoxLayout を使用するコンテナ、あるいは Box ではないコンテナにも便利なクラスメソッドをいくつか提供します。

Box クラスは、レイアウトに影響する、数種類の不可視コンポーネントを作成できます。たとえば、接着剤 (glue)、柱 (strut)、および固定領域 (rigid area) です。ボックスに含まれるすべてのコンポーネントのサイズが固定されている場合は、接着剤コンポーネント (createGlue が返す) を使って、コンポーネントの位置を制御できます。2 つのコンポーネントの間に一定の空間が必要な場合は、柱を使ってみることをお勧めします (createHorizontalStrut または createVerticalStrut)。常に同じ量の空間を占める不可視コンポーネントが必要な場合は、createRigidArea を呼び出してそれを作成することができます。

警告: このクラスの直列化されたオブジェクトは、今後の Swing リリースと互換ではなくなる予定です。現在の直列化のサポートは、短期間の運用や、同じバージョンの Swing を実行するアプリケーション間の RMI に適しています。今後の Swing リリースでは、長期間の持続性をサポートする予定です。

関連項目:
BoxLayout, 直列化された形式

内部クラスの概要
protected  class Box.AccessibleBox
          このクラスは Box クラス用のユーザ補助機能のサポートを実装しています。
static class Box.Filler
          レイアウトに関連し、ビューを持たない軽量コンポーネントの実装です。
 
クラス java.awt.Container から継承した内部クラス
Container.AccessibleAWTContainer
 
クラス java.awt.Component から継承した内部クラス
Component.AccessibleAWTComponent
 
フィールドの概要
protected  AccessibleContext accessibleContext
          現在設定されている AccessibleContext オブジェクトです。
 
クラス java.awt.Component から継承したフィールド
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
インタフェース java.awt.image.ImageObserver から継承したフィールド
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
コンストラクタの概要
Box(int axis)
          指定された軸に沿ってコンポーネントを並べる Box を作成します。
 
メソッドの概要
static Component createGlue()
          不可視の接着剤コンポーネントを作成します。
static Box createHorizontalBox()
          コンポーネントを左から右へ並べる Box を作成します。
static Component createHorizontalGlue()
          水平方向の接着剤コンポーネントを作成します。
static Component createHorizontalStrut(int width)
          不可視の、幅が固定されたコンポーネントを作成します。
static Component createRigidArea(Dimension d)
          常に指定されたサイズである、不可視コンポーネントを作成します。
static Box createVerticalBox()
          コンポーネントを上から下へ並べる Box を作成します。
static Component createVerticalGlue()
          垂直方向の接着剤コンポーネントを作成します。
static Component createVerticalStrut(int height)
          不可視の、高さが固定されたコンポーネントを作成します。
 AccessibleContext getAccessibleContext()
          このボックスに関連した AccessibleContext を返します。
 void setLayout(LayoutManager l)
          AWTError をスローします。
 
クラス java.awt.Container から継承したメソッド
add, add, add, add, add, addContainerListener, addImpl, addNotify, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setFont, update, validate, validateTree
 
クラス java.awt.Component から継承したメソッド
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus
 
クラス java.lang.Object から継承したメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

フィールドの詳細

accessibleContext

protected AccessibleContext accessibleContext
現在設定されている AccessibleContext オブジェクトです。
コンストラクタの詳細

Box

public Box(int axis)
指定された軸に沿ってコンポーネントを並べる Box を作成します。
パラメータ:
axis - BoxLayout.X_AXIS (コンポーネントを左から右へ並べる) または BoxLayout.Y_AXIS (上から下へ並べる)
関連項目:
createHorizontalBox(), createVerticalBox()
メソッドの詳細

createHorizontalBox

public static Box createHorizontalBox()
コンポーネントを左から右へ並べる Box を作成します。
戻り値:
ボックス

createVerticalBox

public static Box createVerticalBox()
コンポーネントを上から下へ並べる Box を作成します。
戻り値:
ボックス

createRigidArea

public static Component createRigidArea(Dimension d)
常に指定されたサイズである、不可視コンポーネントを作成します。
パラメータ:
d - 不可視コンポーネントのサイズ
戻り値:
コンポーネント
関連項目:
createGlue(), createHorizontalStrut(int), createVerticalStrut(int)

createHorizontalStrut

public static Component createHorizontalStrut(int width)
不可視の、幅が固定されたコンポーネントを作成します。水平ボックスでは、このメソッドを使って、2 つのコンポーネントの間隔を固定できます。垂直ボックスでは、このメソッドを使って、ボックスの幅を指定できます。不可視コンポーネントには、空間が余っていない限り高さがありません。空間が余っていれば、高さの最大値の指定がないコンポーネントと同様に、自身に必要な分の空間を占めます。
パラメータ:
width - 不可視コンポーネントの、ピクセル単位の幅 >= 0
戻り値:
コンポーネント
関連項目:
createVerticalStrut(int), createGlue(), createRigidArea(java.awt.Dimension)

createVerticalStrut

public static Component createVerticalStrut(int height)
不可視の、高さが固定されたコンポーネントを作成します。垂直ボックスでは、このメソッドを使って、2 つのコンポーネントの間隔を固定できます。水平ボックスでは、このメソッドを使って、ボックスの幅を指定できます。不可視コンポーネントには、空間が余っていない限り幅がありません。空間が余っていれば、幅の最大値の指定がないコンポーネントと同様に、自身に必要な分の空間を占めます。
パラメータ:
height - 不可視コンポーネントの、ピクセル単位の高さ >= 0
戻り値:
コンポーネント
関連項目:
createHorizontalStrut(int), createGlue(), createRigidArea(java.awt.Dimension)

createGlue

public static Component createGlue()
不可視の接着剤コンポーネントを作成します。これは、可視コンポーネントに最大幅 (水平ボックス) や最大高 (垂直ボックス) が指定されているボックスに便利です。接着剤コンポーネントについては、隣り合うコンポーネントの間隔を埋めるために必要なだけ延びる、糊のようなものだと考えてください。

たとえば、1 つの水平ボックスに、固定サイズのコンポーネントが 2 つ含まれているとします。このボックスに空間が追加されても、固定サイズコンポーネントは大きくなりません。このとき、接着剤がない場合、余った空間は 2 番目のコンポーネントの右に付きます。ここで接着剤を固定サイズコンポーネントの間に置くと、余った空間は接着剤コンポーネントに使われます。接着剤を 1 番目の固定サイズコンポーネントの前に置くと、余った空間は接着剤コンポーネントに使われ、2 つの固定サイズコンポーネントはボックスの右に寄せられます。1 番目の固定サイズコンポーネントの前、および 2 番目の固定サイズコンポーネントのあとに接着剤を置くと、2 つの固定サイズコンポーネントはボックスの中央に寄せられます。

接着剤を使うには、Box.createGlue を呼び出して、返されたコンポーネントをコンテナに追加します。接着剤コンポーネントには、最小のサイズ、あるいは望ましいサイズがありません。そのため、余分な空間がない限り、空間を占めることはありません。余分な空間があれば、接着剤コンポーネントは、利用可能な空間 (水平方向、または垂直方向) を占めます。この場合は、幅あるいは高さの最大値の指定がないコンポーネントと同様です。

戻り値:
コンポーネント

createHorizontalGlue

public static Component createHorizontalGlue()
水平方向の接着剤コンポーネントを作成します。
戻り値:
コンポーネント

createVerticalGlue

public static Component createVerticalGlue()
垂直方向の接着剤コンポーネントを作成します。
戻り値:
コンポーネント

setLayout

public void setLayout(LayoutManager l)
AWTError をスローします。ボックスは、BoxLayout だけを使用できます。
オーバーライド:
クラス Container 内の setLayout
パラメータ:
l - 使用するレイアウトマネージャ

getAccessibleContext

public AccessibleContext getAccessibleContext()
このボックスに関連した AccessibleContext を返します。ボックスの場合、AccessibleContext は AccessibleBox の形式を取ります。必要に応じて新規の AccessibleAWTBox インスタンスが作成されます。
定義:
インタフェース Accessible 内の getAccessibleContext
オーバーライド:
クラス Component 内の getAccessibleContext
戻り値:
このボックスの AccessibleContext として機能する AccessibleBox

JavaTM 2 Platform
Std. Ed. v1.3

バグや機能要求の報告
さらに詳しい API リファレンスおよび開発者ドキュメントについては、 Java 2 SDK SE Developer Documentation を参照してください。このドキュメントには、概念、用語の定義、回避策、 実用的なコード例など、開発者を対象にした詳細な解説が掲載されています。

Java、Java 2D、JDBC は、米国およびその他の国における米国 Sun Microsystems, Inc. の商標もしくは登録商標です。
Copyright 1993-2000 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.