public class Box extends JComponent implements Accessible
Boxクラスは、レイアウトに影響を与えるいくつかの種類の不可視コンポーネント(接着剤、柱および固定領域)を作成できます。Boxに格納されているすべてのコンポーネントが固定のサイズである場合、接着剤コンポーネント(createGlueによって返される)を使用して、コンポーネントの位置を制御する場合があります。2つのコンポーネント間に固定の量のスペースが必要な場合、柱(createHorizontalStrutまたはcreateVerticalStrut)を使用してみてください。常に同じ量のスペースを占める不可視のコンポーネントが必要な場合、createRigidAreaを呼び出して、それを取得します。
BoxLayoutを実装する場合、詳細な情報と例については、『The Java Tutorial』の「How to Use BoxLayout」を参照してください。
警告: このクラスの直列化されたオブジェクトは、今後のSwingリリースと互換ではなくなる予定です。現在の直列化のサポートは、短期間の格納や、同じバージョンのSwingを実行するアプリケーション間のRMIに適しています。1.4以降、すべてのJavaBeans(tm)用の長期間の格納サポートがjava.beansパッケージに追加されています。XMLEncoderを参照してください。
BoxLayout| 修飾子と型 | クラスと説明 |
|---|---|
protected class |
Box.AccessibleBox
このクラスは
Boxクラスのアクセシビリティ・サポートを実装しています。 |
static class |
Box.Filler
レイアウトに含まれるがビューを持たない軽量コンポーネントの実装です。
|
JComponent.AccessibleJComponentContainer.AccessibleAWTContainerComponent.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategylistenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWaccessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH| コンストラクタと説明 |
|---|
Box(int axis)
指定された軸に沿ってコンポーネントを表示する
Boxを生成します。 |
| 修飾子と型 | メソッドと説明 |
|---|---|
static Component |
createGlue()
不可視の「接着剤」コンポーネントを作成します。これは、可視コンポーネントに水平ボックスに対する最大幅や垂直ボックスに対する最大高が指定されているBoxに便利です。
|
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を取得します。
|
protected void |
paintComponent(Graphics g)
この
Boxをペイントします。 |
void |
setLayout(LayoutManager l)
AWTErrorをスローします。BoxはBoxLayoutしか使用できません。
|
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUIadd, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, transferFocusDownCycle, validate, validateTreeaction, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCyclepublic Box(int axis)
Boxを生成します。axis - BoxLayout.X_AXIS、BoxLayout.Y_AXIS、BoxLayout.LINE_AXIS、またはBoxLayout.PAGE_AXIS。AWTError - axisが無効な場合createHorizontalBox(), createVerticalBox()public static Box createHorizontalBox()
Boxを生成します。コンポーネントの方向を考慮したBoxが必要な場合は、コンストラクタを使用してBoxを生成しBoxLayout.LINE_AXISに渡す必要があります。次に例を示します。
Box lineBox = new Box(BoxLayout.LINE_AXIS);
public static Box createVerticalBox()
Boxを生成します。コンポーネントの方向を考慮したBoxが必要な場合は、コンストラクタを使用してBoxを生成しBoxLayout.PAGE_AXISに渡す必要があります。次に例を示します。
Box lineBox = new Box(BoxLayout.PAGE_AXIS);
public static Component createRigidArea(Dimension d)
d - 不可視コンポーネントのサイズcreateGlue(), createHorizontalStrut(int), createVerticalStrut(int)public static Component createHorizontalStrut(int width)
width - 不可視コンポーネントのピクセル単位の幅。値はゼロ以上createVerticalStrut(int), createGlue(), createRigidArea(java.awt.Dimension)public static Component createVerticalStrut(int height)
height - 不可視コンポーネントのピクセル単位の高さ。値はゼロ以上createHorizontalStrut(int), createGlue(), createRigidArea(java.awt.Dimension)public static Component createGlue()
たとえば、1つの水平ボックスに、固定サイズのコンポーネントが2つ含まれているとします。このボックスに空間が追加されても、固定サイズ・コンポーネントは大きくなりません。このとき、接着剤がない場合、2番目のコンポーネントの右の空間が余ります。ここで接着剤を固定サイズ・コンポーネントの間に置くと、余った空間を接着剤コンポーネントが占めます。接着剤を1番目の固定サイズ・コンポーネントの前に置くと、余った空間を接着剤コンポーネントが占め、2つの固定サイズ・コンポーネントはボックスの右に寄せられます。1番目の固定サイズ・コンポーネントの前、および2番目の固定サイズ・コンポーネントのあとに接着剤を置くと、2つの固定サイズ・コンポーネントはボックスの中央に寄せられます。
接着剤を使用するには、Box.createGlueを呼び出し、返されたコンポーネントをコンテナに追加します。接着剤コンポーネントには最小または推奨サイズがないため、余分なスペースがないかぎり、スペースを占めません。余分なスペースがある場合、接着剤コンポーネントは、最大の幅や高さを持たない他のコンポーネントとまったく同じように、使用可能な水平または垂直のスペースのその部分を占めます。
public static Component createHorizontalGlue()
public static Component createVerticalGlue()
public void setLayout(LayoutManager l)
setLayout 、クラス: Containerl - 使用するレイアウト・マネージャContainer.doLayout(), Container.getLayout(), Container.invalidate()protected void paintComponent(Graphics g)
Boxをペイントします。このBoxにUIがある場合、このメソッドは上位実装を呼び出します。UIがなく、このBoxが不透明な場合、Graphicsはバックグラウンド・カラーで塗りつぶされます。paintComponent 、クラス: JComponentg - ペイントされるGraphicsNullPointerException - gがnullである場合JComponent.paint(java.awt.Graphics), ComponentUIpublic AccessibleContext getAccessibleContext()
getAccessibleContext 、インタフェース: AccessiblegetAccessibleContext、クラス: Component バグまたは機能を送信
詳細なAPIリファレンスおよび開発者ドキュメントについては、Java SEのドキュメントを参照してください。そのドキュメントには、概念的な概要、用語の定義、回避方法、有効なコード例などの、開発者を対象にしたより詳細な説明が含まれています。
Copyright© 1993, 2014, Oracle and/or its affiliates. All rights reserved.