クラスBox
- すべての実装されたインタフェース:
ImageObserver,MenuContainer,Serializable,Accessible
Boxクラスは、レイアウトに影響を与えるいくつかの種類の不可視コンポーネント(接着剤、柱および固定領域)を作成できます。 Boxに格納されているすべてのコンポーネントが固定のサイズである場合、接着剤コンポーネント(createGlueによって返される)を使用して、コンポーネントの位置を制御する場合があります。 2つのコンポーネント間に固定の量のスペースが必要な場合、柱(createHorizontalStrutまたはcreateVerticalStrut)を使用してみてください。 常に同じ量のスペースを占める不可視のコンポーネントが必要な場合、createRigidAreaを呼び出して、それを取得します。
BoxLayoutを実装する場合、詳細な情報と例については、『The Java Tutorial』の「How to Use BoxLayout」を参照してください。
警告: このクラスの直列化されたオブジェクトは、今後のSwingリリースと互換ではなくなる予定です。 現在の直列化のサポートは、短期間の格納や、同じバージョンのSwingを実行するアプリケーション間のRMIに適しています。 1.4では、すべてのJavaBeansの長期ストレージのサポートがjava.beansパッケージに追加されました。 XMLEncoderを参照してください。
- 導入されたバージョン:
- 1.2
- 関連項目:
-
ネストされたクラスのサマリー
ネストされたクラス修飾子と型クラス説明protected classこのクラスはBoxクラスのアクセシビリティ・サポートを実装しています。static classレイアウトに含まれるがビューを持たない軽量コンポーネントの実装です。クラスjavax.swing.JComponentで宣言されたネストされたクラス/インタフェース
JComponent.AccessibleJComponentクラスjava.awt.Containerで宣言されたネストされたクラス/インタフェース
Container.AccessibleAWTContainerクラスjava.awt.Componentで宣言されたネストされたクラス/インタフェース
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
フィールドのサマリー
クラスjavax.swing.JComponentで宣言されたフィールド
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWクラスjava.awt.Componentで宣言されたフィールド
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTインタフェースjava.awt.image.ImageObserverで宣言されているフィールド
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
コンストラクタのサマリー
コンストラクタ -
メソッドのサマリー
修飾子と型メソッド説明static Component不可視の「接着剤」コンポーネントを作成します。これは、可視コンポーネントに水平ボックスに対する最大幅や垂直ボックスに対する最大高が指定されているBoxに便利です。static Boxコンポーネントを左から右へ表示するBoxを生成します。static Component水平方向の接着剤コンポーネントを作成します。static ComponentcreateHorizontalStrut(int width) 不可視の固定幅コンポーネントを生成します。static Component常に指定されたサイズである、不可視コンポーネントを生成します。static Boxコンポーネントを上から下へ表示するBoxを生成します。static Component垂直方向の接着剤コンポーネントを作成します。static ComponentcreateVerticalStrut(int height) 不可視の、高さが固定されたコンポーネントを作成します。このボックスに関連付けられたAccessibleContextを取得します。protected voidこのBoxをペイントします。voidAWTErrorをスローします。BoxはBoxLayoutしか使用できません。クラスjavax.swing.JComponentで宣言されたメソッド
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, 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, getUI, 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, updateUIクラスjava.awt.Containerで宣言されたメソッド
add, 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, validateTreeクラスjava.awt.Componentで宣言されたメソッド
action, 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, 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, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
コンストラクタの詳細
-
Box
public Box(int axis) 指定された軸に沿ってコンポーネントを表示するBoxを作成します。- パラメータ:
axis-BoxLayout.X_AXIS、BoxLayout.Y_AXIS、BoxLayout.LINE_AXIS、またはBoxLayout.PAGE_AXIS。- スロー:
AWTError-axisが無効な場合- 関連項目:
-
-
メソッドの詳細
-
createHorizontalBox
public static Box createHorizontalBox()コンポーネントを左から右へ表示するBoxを生成します。 コンポーネントの方向を考慮したBoxが必要な場合は、コンストラクタを使用してBoxを生成しBoxLayout.LINE_AXISに渡す必要があります。次に例を示します。Box lineBox = new Box(BoxLayout.LINE_AXIS);
- 戻り値:
- ボックス
-
createVerticalBox
public static Box createVerticalBox()コンポーネントを上から下へ表示するBoxを生成します。 コンポーネントの方向を考慮したBoxが必要な場合は、コンストラクタを使用してBoxを生成しBoxLayout.PAGE_AXISに渡す必要があります。次に例を示します。Box lineBox = new Box(BoxLayout.PAGE_AXIS);
- 戻り値:
- ボックス
-
createRigidArea
-
createHorizontalStrut
public static Component createHorizontalStrut(int width) 不可視の固定幅コンポーネントを生成します。 水平ボックスでは、一般にこのメソッドを使用して、2つのコンポーネント間に特定の量のスペースを適用します。 垂直ボックスでは、このメソッドを使用して、ボックスを少なくとも指定した幅にすることが可能です。 余分なスペースがないかぎり、不可視のコンポーネントには高さがありません。余分なスペースがある場合は、最大高のない他のコンポーネントとまったく同じように、使用可能なスペースのその部分を占めます。- パラメータ:
width- 不可視コンポーネントのピクセル単位の幅。値はゼロ以上- 戻り値:
- コンポーネント
- 関連項目:
-
createVerticalStrut
public static Component createVerticalStrut(int height) 不可視の、高さが固定されたコンポーネントを作成します。 垂直ボックスでは、一般にこのメソッドを使用して、2つのコンポーネント間に特定の量のスペースを適用します。 水平ボックスでは、このメソッドを使用して、ボックスを少なくとも指定した高さにすることが可能です。 余分なスペースがないかぎり、不可視のコンポーネントには幅がありません。余分なスペースがある場合は、最大幅のない他のコンポーネントとまったく同じように、使用可能なスペースのその部分を占めます。- パラメータ:
height- 不可視コンポーネントのピクセル単位の高さ。値はゼロ以上- 戻り値:
- コンポーネント
- 関連項目:
-
createGlue
public static Component createGlue()不可視の「接着剤」コンポーネントを作成します。これは、可視コンポーネントに水平ボックスに対する最大幅や垂直ボックスに対する最大高が指定されているBoxに便利です。 接着剤コンポーネントは、その隣接コンポーネントの間のスペースを埋めるために必要な量だけ拡張する、粘着性のある物質と考えることができます。たとえば、1つの水平ボックスに、固定サイズのコンポーネントが2つ含まれているとします。 このボックスに空間が追加されても、固定サイズ・コンポーネントは大きくなりません。 このとき、接着剤がない場合、2番目のコンポーネントの右の空間が余ります。 ここで接着剤を固定サイズ・コンポーネントの間に置くと、余った空間を接着剤コンポーネントが占めます。 接着剤を1番目の固定サイズ・コンポーネントの前に置くと、余った空間を接着剤コンポーネントが占め、2つの固定サイズ・コンポーネントはボックスの右に寄せられます。 1番目の固定サイズ・コンポーネントの前、および2番目の固定サイズ・コンポーネントのあとに接着剤を置くと、2つの固定サイズ・コンポーネントはボックスの中央に寄せられます。
接着剤を使用するには、
Box.createGlueを呼び出し、返されたコンポーネントをコンテナに追加します。 接着剤コンポーネントには最小または推奨サイズがないため、余分なスペースがないかぎり、スペースを占めません。 余分なスペースがある場合、接着剤コンポーネントは、最大の幅や高さを持たない他のコンポーネントとまったく同じように、使用可能な水平または垂直のスペースのその部分を占めます。- 戻り値:
- コンポーネント
-
createHorizontalGlue
-
createVerticalGlue
-
setLayout
public void setLayout(LayoutManager l) AWTErrorをスローします。BoxはBoxLayoutしか使用できません。 -
paintComponent
protected void paintComponent(Graphics g) このBoxをペイントします。 このBoxにUIがある場合、このメソッドは上位実装を呼び出します。UIがなく、このBoxが不透明な場合、Graphicsはバックグラウンド・カラーで塗りつぶされます。- オーバーライド:
paintComponent、クラスJComponent- パラメータ:
g- ペイントされるGraphics- スロー:
NullPointerException-gがnullである場合- 導入されたバージョン:
- 1.6
- 関連項目:
-
getAccessibleContext
@BeanProperty(bound=false) public AccessibleContext getAccessibleContext()このボックスに関連付けられたAccessibleContextを取得します。 ボックスの場合、AccessibleContextはAccessibleBoxの形式を取ります。 必要に応じて新規のAccessibleAWTBoxインスタンスが生成されます。- 定義:
getAccessibleContext、インタフェースAccessible- オーバーライド:
getAccessibleContext、クラスComponent- 戻り値:
- このBoxのAccessibleContextとして機能するAccessibleBox
-