クラスJLayeredPane
- すべての実装されたインタフェース:
ImageObserver,MenuContainer,Serializable,Accessible
- 直系の既知のサブクラス:
JDesktopPane
JLayeredPaneはJFC/Swingコンテナに深さを追加し、コンポーネントが必要に応じて互いにオーバーラップできるようにします。 Integerオブジェクトはコンテナ内での各コンポーネントの深さを表し、番号が大きいほどほかのコンポーネント「の上」に表示されます。 階層化ペインに関するタスク指向のドキュメントおよび使用例は、「The Java Tutorial」の「How to Use a Layered Pane」を参照してください。
例:
JLayeredPaneは深さの範囲をいくつかのレイヤーに分割しています。 コンポーネントをこれらのレイヤーのどれかに配置することで、深さを指定する番号を指定することなしに、コンポーネントを適切にオーバーラップさせることができます。
- DEFAULT_LAYER
- ほとんどのコンポーネントが配置される標準レイヤーです。 最下層のレイヤーとなります。
- PALETTE_LAYER
- パレット・レイヤーは、デフォルト・レイヤーの上に表示されます。 ドラッグ可能なツールバーやパレットは、ほかのコンポーネントの上に表示されるように、このレイヤーに配置すると便利です。
- MODAL_LAYER
- モーダル・ダイアログ用のレイヤーです。 モーダル・ダイアログは、コンテナ内のツールバー、パレット、および標準コンポーネントの上に表示されます。
- POPUP_LAYER
- ポップアップ・レイヤーは、ダイアログの上に表示されます。 このレイヤーにより、コンボボックス、ツールヒント、およびその他のヘルプ・テキストに関連したポップアップ・ウィンドウは、そのポップアップ・ウィンドウを生成したコンポーネント、パレット、またはダイアログの上に表示されます。
- DRAG_LAYER
- コンポーネントをドラッグする際には、そのコンポーネントをドラッグ・レイヤーに割り当てることによって、コンテナ内のほかのすべてのコンポーネントより上に表示させることができます。 ドラッグが完了したら、そのコンポーネントを元のレイヤーに割当て直すことができます。
JLayeredPaneのメソッドであるmoveToFront(Component)、moveToBack(Component)、およびsetPositionを使用することで、レイヤー内でコンポーネントを再配置することができます。 setLayerメソッドを使用すると、コンポーネントの現在のレイヤーを変更することができます。
詳細
JLayeredPaneは、Containerと同じように子のリストを管理しますが、内部で複数のレイヤーを定義することができます。 同じレイヤーに属する子は、通常のContainerオブジェクトとまったく同じように管理されますが、子コンポーネントどうしがオーバーラップした場合には、上位のレイヤーのコンポーネントの方が下位レイヤーのコンポーネントより上に表示されます。
各レイヤーには個別の整数値が割り当てられます。 Componentのレイヤー属性を設定するには、add呼出しでIntegerオブジェクトを渡します。
たとえば:
layeredPane.add(child, JLayeredPane.DEFAULT_LAYER);
or
layeredPane.add(child, Integer.valueOf(10));
Componentのレイヤー属性を設定するには、
layeredPaneParent.setLayer(child, 10)
をコンポーネントの親であるJLayeredPane上で呼び出すこともできます。 レイヤーは、子を親に追加する前に設定する必要があります。
番号が大きいレイヤーほど上に表示されます。 したがって、次のように各コンポーネントに個別のレイヤー番号と文字を割り当てることにより、
5a, 5b, 5c, 2a, 2b, 2c, 1a
左のコンポーネントほど上に表示されます。
コンポーネントをレイヤー内でいちばん上またはいちばん下に移動させるには、moveToFrontまたはmoveToBackを呼び出します。
レイヤー内でのコンポーネントの位置を位置番号で指定することもできます。 指定できる位置番号は、0から「レイヤー内のコンポーネント数 - 1」です。 -1を指定すると、コンポーネントはいちばん下に表示されます。 0を指定すると、コンポーネントはいちばん上に表示されます。 レイヤー番号とは異なり、値が大きいほど下に表示されます。
ノート: この順序(java.awt.Containerで定義されている)は、レイヤー番号の順序の反対になっています。 通常は、add(Component, layer, position)メソッドの使用例を示します。add(5x, 5, -1)呼出しの結果は次のとおりです。moveToFront、moveToBack、およびsetLayerを使用します。
5a, 5b, 5c, 5x, 2a, 2b, 2c, 1a
add(5z, 5, 2)呼出しの結果は次のとおりです。
5a, 5b, 5z, 5c, 5x, 2a, 2b, 2c, 1a
add(3a, 3, 7)呼出しの結果は次のとおりです。
5a, 5b, 5z, 5c, 5x, 3a, 2a, 2b, 2c, 1a
通常のペイント/イベント方式では、1aがいちばん下、5aがいちばん上に表示されます。
ノート: これらのレイヤーは単に論理的な構造であり、LayoutManagerは、レイヤー設定には関係なく、このコンテナのすべての子コンポーネントに影響します。
警告: Swingはスレッドに対して安全ではありません。 詳細は、「Swing's Threading Policy」を参照してください。
警告: このクラスの直列化されたオブジェクトは、今後のSwingリリースと互換ではなくなる予定です。 現在の直列化のサポートは、短期間の格納や、同じバージョンのSwingを実行するアプリケーション間のRMIに適しています。 1.4では、すべてのJavaBeansの長期ストレージのサポートがjava.beansパッケージに追加されました。 XMLEncoderを参照してください。
- 導入されたバージョン:
- 1.2
-
ネストされたクラスのサマリー
ネストされたクラス修飾子と型クラス説明protected classこのクラスはJLayeredPaneクラスのアクセシビリティ・サポートを実装しています。クラスjavax.swing.JComponentで宣言されたネストされたクラス/インタフェース
JComponent.AccessibleJComponentクラスjava.awt.Containerで宣言されたネストされたクラス/インタフェース
Container.AccessibleAWTContainerクラスjava.awt.Componentで宣言されたネストされたクラス/インタフェース
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
フィールドのサマリー
フィールド修飾子と型フィールド説明static final Integerデフォルト・レイヤーを定義する簡易オブジェクトです。static final Integerドラッグ・レイヤーを定義する簡易オブジェクトです。static final Integerフレーム内容レイヤーを定義する簡易オブジェクトです。static final Stringバウンド・プロパティです。static final Integerモーダル・レイヤーを定義する簡易オブジェクトです。static final Integerパレット・レイヤーを定義する簡易オブジェクトです。static final Integerポップアップ・レイヤーを定義する簡易オブジェクトです。クラス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 -
コンストラクタのサマリー
コンストラクタ -
メソッドのサマリー
修飾子と型メソッド説明このJLayeredPaneに関連付けられたAccessibleContextを取得します。intgetComponentCountInLayer(int layer) 指定されたレイヤーの現在の子の数を返します。getComponentsInLayer(int layer) 指定されたレイヤーのコンポーネントの配列を返します。コンポーネントをレイヤーにマッピングするハッシュ・テーブルを返します。int指定されたComponentのインデックスを返します。int指定されたComponentのレイヤー属性を返します。static intJComponentのレイヤー・プロパティを返します。このメソッドは、setLayer()のような副作用(ペイント、追加/削除など)はありません。static JLayeredPane指定されたコンポーネントを含む最初のJLayeredPaneを返す簡易メソッドです。protected IntegergetObjectForLayer(int layer) 指定されたレイヤーに関連したIntegerオブジェクトを返します。intレイヤー内でのコンポーネントの相対位置を返します。int現在のすべての子から最大レイヤー値を返します。protected intinsertIndexForLayer(int layer, int position) レイヤーおよび位置の要求に従って新しい子を挿入する適切な位置を決定するためのプリミティブ・メソッドです。booleanペイン内のコンポーネントがオーバーラップ可能である場合にはfalseを返します。この場合、最適な描画は不可能です。int現在のすべての子から最小レイヤー値を返します。voidコンポーネントを現在のレイヤーでいちばん下(位置 -1)に移動します。voidコンポーネントを現在のレイヤーでいちばん上(位置0)に移動します。void指定されたグラフィックス・コンテキストで、このJLayeredPaneをペイントします。protected StringこのJLayeredPaneの文字列表現を返します。static voidputLayer(JComponent c, int layer) JComponentのレイヤー・プロパティを設定します。voidremove(int index) このペインからインデックス付きのコンポーネントを削除します。voidこのコンテナからすべてのコンポーネントを削除します。void指定されたコンポーネントのレイヤー属性を設定し、レイヤー内でいちばん下のコンポーネントとします。void指定されたコンポーネントのレイヤー属性と、レイヤー内でのコンポーネントの位置を指定します。voidsetPosition(Component c, int position) コンポーネントを現在のレイヤーのpositionに移動します。0がいちばん上、-1がいちばん下です。クラス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, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, 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, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, 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
-
フィールド詳細
-
DEFAULT_LAYER
public static final Integer DEFAULT_LAYERデフォルト・レイヤーを定義する簡易オブジェクトです。 同等のtoInteger.valueOf(0)。 -
PALETTE_LAYER
public static final Integer PALETTE_LAYERパレット・レイヤーを定義する簡易オブジェクトです。 Integer.valueOf(100)と同等です。 -
MODAL_LAYER
public static final Integer MODAL_LAYERモーダル・レイヤーを定義する簡易オブジェクトです。 Integer.valueOf(200)と同等です。 -
POPUP_LAYER
public static final Integer POPUP_LAYERポップアップ・レイヤーを定義する簡易オブジェクトです。 Integer.valueOf(300)と同等です。 -
DRAG_LAYER
public static final Integer DRAG_LAYERドラッグ・レイヤーを定義する簡易オブジェクトです。 Integer.valueOf(400)と同等です。 -
FRAME_CONTENT_LAYER
public static final Integer FRAME_CONTENT_LAYERフレーム内容レイヤーを定義する簡易オブジェクトです。 このレイヤーは通常、JFrameのcontentPaneおよびmenuBarコンポーネントを配置するためにのみ使用します。 Integer.valueOf(-30000)と同等です。- 関連項目:
-
LAYER_PROPERTY
-
-
コンストラクタの詳細
-
JLayeredPane
public JLayeredPane()新しいJLayeredPaneを作成します。
-
-
メソッドの詳細
-
remove
-
removeAll
-
isOptimizedDrawingEnabled
@BeanProperty(bound=false) public boolean isOptimizedDrawingEnabled()ペイン内のコンポーネントがオーバーラップ可能である場合にはfalseを返します。この場合、最適な描画は不可能です。 そうでない場合はtrueを返します。- オーバーライド:
isOptimizedDrawingEnabled、クラスJComponent- 戻り値:
- コンポーネントがオーバーラップ可能である場合はfalse、そうでない場合はtrue
- 関連項目:
-
putLayer
public static void putLayer(JComponent c, int layer) JComponentのレイヤー・プロパティを設定します。 このメソッドは、setLayer()のような副作用(ペイント、追加/削除など)はありません。 通常は、必要な副作用(再ペイントなど)を得るために、インスタンス・メソッドのsetLayer()を使用します。- パラメータ:
c- 移動するJComponentlayer- 移動先のレイヤーを指定するint値- 関連項目:
-
getLayer
public static int getLayer(JComponent c) JComponentのレイヤー・プロパティを返します。このメソッドは、setLayer()のような副作用(ペイント、追加/削除など)はありません。通常は、インスタンス・メソッドのgetLayer()を使用するようにしてください。- パラメータ:
c- チェック対象のJComponent- 戻り値:
- コンポーネントのレイヤーを指定するint値
-
getLayeredPaneAbove
public static JLayeredPane getLayeredPaneAbove(Component c) 指定されたコンポーネントを含む最初のJLayeredPaneを返す簡易メソッドです。 すべてのJFrameは、ルートにJLayeredPaneを持つため、JFrameのすべてのコンポーネントはJLayeredPaneを親として持ちます。- パラメータ:
c- チェック対象のComponent- 戻り値:
- コンポーネントを含むJLayeredPane。コンポーネント階層にJLayeredPaneが含まれていない場合はnull
- 関連項目:
-
setLayer
public void setLayer(Component c, int layer) 指定されたコンポーネントのレイヤー属性を設定し、レイヤー内でいちばん下のコンポーネントとします。 親に追加する前に呼び出す必要があります。- パラメータ:
c- レイヤーを設定するComponentlayer- 設定するレイヤーを指定するint値。値が小さいほど下層
-
setLayer
public void setLayer(Component c, int layer, int position) 指定されたコンポーネントのレイヤー属性と、レイヤー内でのコンポーネントの位置を指定します。- パラメータ:
c- レイヤーを設定するComponentlayer- 設定するレイヤーを指定するint値。値が小さいほど下層position- レイヤー内での位置を指定するint値。0がいちばん上、-1がいちばん下
-
getLayer
public int getLayer(Component c) 指定されたComponentのレイヤー属性を返します。- パラメータ:
c- チェック対象のComponent- 戻り値:
- コンポーネントの現在のレイヤーを指定するint値
-
getIndexOf
public int getIndexOf(Component c) 指定されたComponentのインデックスを返します。 絶対インデックスであり、レイヤーは無視します。 インデックス番号は、位置番号と同じように、一番上のコンポーネントの番号が0になります。 値が大きいほど一番下に近くなります。- パラメータ:
c- チェック対象のComponent- 戻り値:
- コンポーネントのインデックスを指定するint値
-
moveToFront
public void moveToFront(Component c) コンポーネントを現在のレイヤーでいちばん上(位置0)に移動します。- パラメータ:
c- 移動するComponent- 関連項目:
-
moveToBack
public void moveToBack(Component c) コンポーネントを現在のレイヤーでいちばん下(位置 -1)に移動します。- パラメータ:
c- 移動するComponent- 関連項目:
-
setPosition
public void setPosition(Component c, int position) コンポーネントを現在のレイヤーのpositionに移動します。0がいちばん上、-1がいちばん下です。ノート: 位置番号はjava.awt.Containerによって定義されており、レイヤー番号の順序の反対になっています。 位置番号が小さいほど上(0がいちばん上)、大きいほど下になります。
- パラメータ:
c- 移動するComponentposition- -1からN-1 (Nは現在のレイヤーのコンポーネント数)の範囲内のint値
-
getPosition
public int getPosition(Component c) レイヤー内でのコンポーネントの相対位置を返します。- パラメータ:
c- チェック対象のComponent- 戻り値:
- コンポーネントの位置を指定するint。0は最上位の位置、最も高いインデックス値=そのレイヤーのコンポーネントの数から1を引いた値
- 関連項目:
-
highestLayer
public int highestLayer()現在のすべての子から最大レイヤー値を返します。 子が存在しない場合には0を返します。- 戻り値:
- ペイン内のいちばん上のコンポーネントのレイヤーを示すint値。子が存在しない場合は0
-
lowestLayer
public int lowestLayer()現在のすべての子から最小レイヤー値を返します。 子が存在しない場合には0を返します。- 戻り値:
- ペイン内のいちばん下のコンポーネントのレイヤーを示すint値。子が存在しない場合は0
-
getComponentCountInLayer
public int getComponentCountInLayer(int layer) 指定されたレイヤーの現在の子の数を返します。- パラメータ:
layer- チェックするレイヤーを指定するint値- 戻り値:
- レイヤーのコンポーネント数を指定するint値
-
getComponentsInLayer
public Component[] getComponentsInLayer(int layer) 指定されたレイヤーのコンポーネントの配列を返します。- パラメータ:
layer- チェックするレイヤーを指定するint値- 戻り値:
- レイヤーに含まれているComponentの配列
-
paint
public void paint(Graphics g) 指定されたグラフィックス・コンテキストで、このJLayeredPaneをペイントします。- オーバーライド:
paint、クラスJComponent- パラメータ:
g- ペイント先となるGraphicsコンテキスト- 関連項目:
-
getComponentToLayer
-
getObjectForLayer
protected Integer getObjectForLayer(int layer) 指定されたレイヤーに関連したIntegerオブジェクトを返します。- パラメータ:
layer- レイヤーを指定するint値- 戻り値:
- レイヤーのIntegerオブジェクト
-
insertIndexForLayer
protected int insertIndexForLayer(int layer, int position) レイヤーおよび位置の要求に従って新しい子を挿入する適切な位置を決定するためのプリミティブ・メソッドです。- パラメータ:
layer- レイヤーを指定するint値position- レイヤー内の位置を指定するint値- 戻り値:
- (絶対)挿入インデックスを指定するint値
- 関連項目:
-
paramString
protected String paramString()このJLayeredPaneの文字列表現を返します。 このメソッドはデバッグ専用であり、返される文字列の内容および形式は実装によって異なる可能性があります。 返される文字列は空でもかまいませんが、nullにはできません。- オーバーライド:
paramString、クラスJComponent- 戻り値:
- このJLayeredPaneの文字列表現
-
getAccessibleContext
@BeanProperty(bound=false) public AccessibleContext getAccessibleContext()このJLayeredPaneに関連付けられたAccessibleContextを取得します。 階層化ペインの場合、AccessibleContextはAccessibleJLayeredPaneの形式を取ります。 必要に応じて新規のAccessibleJLayeredPaneインスタンスが作成されます。- 定義:
getAccessibleContext、インタフェースAccessible- オーバーライド:
getAccessibleContext、クラスComponent- 戻り値:
- このJLayeredPaneのAccessibleContextとして機能するAccessibleJLayeredPane
-