JavaTM Platform
Standard Ed. 6

javax.swing
クラス JPopupMenu

java.lang.Object
  上位を拡張 java.awt.Component
      上位を拡張 java.awt.Container
          上位を拡張 javax.swing.JComponent
              上位を拡張 javax.swing.JPopupMenu
すべての実装されたインタフェース:
ImageObserver, MenuContainer, Serializable, Accessible, MenuElement
直系の既知のサブクラス:
BasicComboPopup

public class JPopupMenu
extends JComponent
implements Accessible, MenuElement

ポップアップメニューの実装です。 ポップアップメニューは小さなウィンドウで、複数の選択肢 (メニューコマンド) を表示します。JPopupMenu は、メニューバー上の項目が選択されたときに表示するメニューに使用します。また、選択したメニュー項目によっては表示されることもある、プルライトメニューにも使用されます。あるいは、メニューを表示するほかの場所 (メニューバー以外の場所) でも、JPopupMenu を使用できます。たとえば、特定の場所で右クリックが発生した場合のポップアップメニュー表示 (ショートカットメニュー) などです。

ポップアップメニューの使用方法の詳細と例については、「The Java Tutorial」の「How to Use Menus」を参照してください。

警告: Swing はスレッドに対して安全ではありません。詳細は、「Swing's Threading Policy」を参照してください。

警告: このクラスの直列化されたオブジェクトは、今後の Swing リリースと互換ではなくなる予定です。現在の直列化のサポートは、短期間の運用や、同じバージョンの Swing を実行するアプリケーション間の RMI に適しています。JDK Version 1.4 以降、すべての JavaBeans の長期間の運用サポートは、java.beans パッケージに追加されています。詳細は、XMLEncoder を参照してください。


入れ子のクラスの概要
protected  class JPopupMenu.AccessibleJPopupMenu
          このクラスは JPopupMenu クラス用のアクセシビリティーサポートを実装しています。
static class JPopupMenu.Separator
          ポップアップメニュー固有のセパレータです。
 
クラス javax.swing.JComponent から継承された入れ子のクラス/インタフェース
JComponent.AccessibleJComponent
 
クラス java.awt.Container から継承された入れ子のクラス/インタフェース
Container.AccessibleAWTContainer
 
クラス java.awt.Component から継承された入れ子のクラス/インタフェース
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
フィールドの概要
 
クラス javax.swing.JComponent から継承されたフィールド
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
クラス 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
 
コンストラクタの概要
JPopupMenu()
          呼び出しコンポーネントの定義なしで JPopupMenu を構築します。
JPopupMenu(String label)
          指定されたタイトルの PopupMenu を構築します。
 
メソッドの概要
 JMenuItem add(Action a)
          メニューの末尾に、指定された Action オブジェクトを振り分けるメニュー項目を追加します。
 JMenuItem add(JMenuItem menuItem)
          指定されたメニュー項目をメニューの末尾に追加します。
 JMenuItem add(String s)
          指定されたテキストを持つ新しいメニュー項目を作成して、このメニューの末尾に追加します。
 void addMenuKeyListener(MenuKeyListener l)
          ポップアップメニューに MenuKeyListener を追加します。
 void addPopupMenuListener(PopupMenuListener l)
          PopupMenu リスナーを追加します。
 void addSeparator()
          メニューの末尾に新しいセパレータを追加します。
protected  PropertyChangeListener createActionChangeListener(JMenuItem b)
          Action に対する変更が発生した場合にコントロールを更新する、適切に設定された PropertyChangeListener を返します。
protected  JMenuItem createActionComponent(Action a)
          JPopupMenu に追加された ActionJMenuItem を作成するファクトリメソッドです。
protected  void firePopupMenuCanceled()
          PopupMenuListener に、ポップアップメニューが取り消されたことを通知します。
protected  void firePopupMenuWillBecomeInvisible()
          PopupMenuListener に、ポップアップメニューが不可視になることを通知します。
protected  void firePopupMenuWillBecomeVisible()
          PopupMenuListener に、ポップアップメニューが可視になることを通知します。
 AccessibleContext getAccessibleContext()
          この JPopupMenu に関連した AccessibleContext を返します。
 Component getComponent()
          この JPopupMenu コンポーネントを返します。
 Component getComponentAtIndex(int i)
          推奨されていません。 Container.getComponent(int) で置き換えられました。
 int getComponentIndex(Component c)
          指定されたコンポーネントのインデックスを返します。
static boolean getDefaultLightWeightPopupEnabled()
          defaultLightWeightPopupEnabled プロパティーを取得します。
 Component getInvoker()
          ポップアップメニューの呼び出しコンポーネントを返します。
 String getLabel()
          ポップアップメニューのラベルを返します。
 Insets getMargin()
          ポップアップメニューのボーダーと内容の間にあるマージンの値を返します (ピクセル単位)。
 MenuKeyListener[] getMenuKeyListeners()
          この JPopupMenu に addMenuKeyListener() で追加されたすべての MenuKeyListener の配列を返します。
 PopupMenuListener[] getPopupMenuListeners()
          この JMenuItem に addPopupMenuListener() で追加されたすべての PopupMenuListener の配列を返します。
 SingleSelectionModel getSelectionModel()
          単一の選択を扱うモデルオブジェクトを返します。
 MenuElement[] getSubElements()
          このメニューコンポーネントのサブメニューを格納する MenuElement の配列を返します。
 PopupMenuUI getUI()
          このコンポーネントを描画する Look & Feel (L&F) オブジェクトを返します。
 String getUIClassID()
          このコンポーネントを描画する L&F クラスの名前を返します。
 void insert(Action a, int index)
          指定された Action オブジェクトを、メニュー項目として指定の位置に挿入します。
 void insert(Component component, int index)
          指定されたコンポーネントを、メニューの指定された位置に挿入します。
 boolean isBorderPainted()
          ボーダーをペイントするかどうかを調べます。
 boolean isLightWeightPopupEnabled()
          lightWeightPopupEnabled プロパティーを取得します。
 boolean isPopupTrigger(MouseEvent e)
          JPopupMenu の現在インストールされている UI が MouseEvent をポップアップトリガーと見なす場合は、true を返します。
 boolean isVisible()
          ポップアップメニューが可視 (現在表示中) である場合に true を返します。
 void menuSelectionChanged(boolean isIncluded)
          このメニューをアクティブにするか、アクティブではなくするためにメニューバーの選択が変更されたときに、メッセージを送ります。
 void pack()
          コンテナをレイアウトして、内容の表示に最小限の空間を使用するようにします。
protected  void paintBorder(Graphics g)
          borderPainted プロパティーが true である場合に、ポップアップメニューのボーダーをペイントします。
protected  String paramString()
          この JPopupMenu の文字列表現を返します。
protected  void processFocusEvent(FocusEvent evt)
          このコンポーネントで発生するフォーカスイベントを、登録されているすべての FocusListener オブジェクトにディスパッチすることにより処理します。
protected  void processKeyEvent(KeyEvent evt)
          ニーモニックやアクセラレータなどの、キーストロークイベントを処理します。
 void processKeyEvent(KeyEvent e, MenuElement[] path, MenuSelectionManager manager)
          MenuSelectionManager から転送されるキーイベントを処理します。
 void processMouseEvent(MouseEvent event, MenuElement[] path, MenuSelectionManager manager)
          このメソッドは MenuElement インタフェースに適合するために必要ですが、実装されていません。
 void remove(int pos)
          指定されたインデックスにあるコンポーネントをこのポップアップメニューから削除します。
 void removeMenuKeyListener(MenuKeyListener l)
          ポップアップメニューから MenuKeyListener を削除します。
 void removePopupMenuListener(PopupMenuListener l)
          PopupMenu リスナーを削除します。
 void setBorderPainted(boolean b)
          ボーダーをペイントするかどうかを設定します。
static void setDefaultLightWeightPopupEnabled(boolean aFlag)
          lightWeightPopupEnabled プロパティーのデフォルト値を設定します。
 void setInvoker(Component invoker)
          ポップアップメニューの呼び出しコンポーネント、すなわち、ポップアップメニュー項目が表示されるコンポーネントを設定します。
 void setLabel(String label)
          ポップアップメニューのラベルを設定します。
 void setLightWeightPopupEnabled(boolean aFlag)
          lightWeightPopupEnabled のデフォルト値を設定します。
 void setLocation(int x, int y)
          x、y 座標を使って、ポップアップメニューの左上隅の位置を設定します。
 void setPopupSize(Dimension d)
          Dimension オブジェクトを使用して、Popup ウィンドウのサイズを設定します。
 void setPopupSize(int width, int height)
          ポップアップウィンドウのサイズを、指定された幅および高さに設定します。
 void setSelected(Component sel)
          現在選択されるコンポーネントを設定します。
 void setSelectionModel(SingleSelectionModel model)
          単一の選択を扱うモデルオブジェクトを設定します。
 void setUI(PopupMenuUI ui)
          このコンポーネントを描画する L&F オブジェクトを設定します。
 void setVisible(boolean b)
          ポップアップメニューの可視性を設定します。
 void show(Component invoker, int x, int y)
          呼び出しコンポーネント内の x、y 座標で指定された位置に、ポップアップメニューを表示します。
 void updateUI()
          現在の Look & Feel からの値に UI プロパティーをリセットします。
 
クラス javax.swing.JComponent から継承されたメソッド
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, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, 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, unregisterKeyboardAction, update
 
クラス 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, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, 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, 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, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, 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, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
クラス java.lang.Object から継承されたメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

コンストラクタの詳細

JPopupMenu

public JPopupMenu()
呼び出しコンポーネントの定義なしで JPopupMenu を構築します。


JPopupMenu

public JPopupMenu(String label)
指定されたタイトルの PopupMenu を構築します。

パラメータ:
label - ポップアップメニューのタイトルとして UI が使用できる文字列
メソッドの詳細

setDefaultLightWeightPopupEnabled

public static void setDefaultLightWeightPopupEnabled(boolean aFlag)
lightWeightPopupEnabled プロパティーのデフォルト値を設定します。

パラメータ:
aFlag - ポップアップが軽量の場合は true、そうでない場合は false
関連項目:
getDefaultLightWeightPopupEnabled(), setLightWeightPopupEnabled(boolean)

getDefaultLightWeightPopupEnabled

public static boolean getDefaultLightWeightPopupEnabled()
defaultLightWeightPopupEnabled プロパティーを取得します。デフォルトでは true です。

戻り値:
defaultLightWeightPopupEnabled プロパティーの値
関連項目:
setDefaultLightWeightPopupEnabled(boolean)

getUI

public PopupMenuUI getUI()
このコンポーネントを描画する Look & Feel (L&F) オブジェクトを返します。

戻り値:
コンポーネントを描画する PopupMenuUI オブジェクト

setUI

public void setUI(PopupMenuUI ui)
このコンポーネントを描画する L&F オブジェクトを設定します。

パラメータ:
ui - 新規 PopupMenuUI L&F オブジェクト
関連項目:
UIDefaults.getUI(javax.swing.JComponent)

updateUI

public void updateUI()
現在の Look & Feel からの値に UI プロパティーをリセットします。

オーバーライド:
クラス JComponent 内の updateUI
関連項目:
JComponent.updateUI()

getUIClassID

public String getUIClassID()
このコンポーネントを描画する L&F クラスの名前を返します。

オーバーライド:
クラス JComponent 内の getUIClassID
戻り値:
文字列「PopupMenuUI」
関連項目:
JComponent.getUIClassID(), UIDefaults.getUI(javax.swing.JComponent)

processFocusEvent

protected void processFocusEvent(FocusEvent evt)
クラス Component の記述:
このコンポーネントで発生するフォーカスイベントを、登録されているすべての FocusListener オブジェクトにディスパッチすることにより処理します。

このコンポーネントに対してフォーカスイベントが使用可能でない場合、このメソッドは呼び出されません。フォーカスイベントは、次のいずれかの場合に使用可能になります。  

フォーカスイベントが Component に対して使用可能になっている場合、現在の KeyboardFocusManager によって、フォーカスイベントを登録された FocusListener オブジェクトにディスパッチする必要があるかどうかが判断されます。イベントをディスパッチする場合、KeyboardFocusManagerComponentdispatchEvent メソッドを呼び出すため、ComponentprocessFocusEvent メソッドが呼び出されます。

フォーカスイベントが Component に対して使用可能になっている場合、FocusEvent を引数として ComponentdispatchEvent メソッドを呼び出すと、現在の KeyboardFocusManager に関係なく、ComponentprocessFocusEvent メソッドが呼び出されます。

 

イベントパラメータが null の場合の動作は定義されていないため例外がスローされます。

オーバーライド:
クラス Component 内の processFocusEvent
パラメータ:
evt - フォーカスイベント
関連項目:
FocusEvent, FocusListener, KeyboardFocusManager, Component.addFocusListener(java.awt.event.FocusListener), Component.enableEvents(long), Component.dispatchEvent(java.awt.AWTEvent)

processKeyEvent

protected void processKeyEvent(KeyEvent evt)
ニーモニックやアクセラレータなどの、キーストロークイベントを処理します。

オーバーライド:
クラス JComponent 内の processKeyEvent
パラメータ:
evt - 処理されるキーイベント
関連項目:
KeyEvent, KeyListener, KeyboardFocusManager, DefaultKeyboardFocusManager, Component.processEvent(java.awt.AWTEvent), Component.dispatchEvent(java.awt.AWTEvent), Component.addKeyListener(java.awt.event.KeyListener), Component.enableEvents(long), Component.isShowing()

getSelectionModel

public SingleSelectionModel getSelectionModel()
単一の選択を扱うモデルオブジェクトを返します。

戻り値:
selectionModel プロパティー
関連項目:
SingleSelectionModel

setSelectionModel

public void setSelectionModel(SingleSelectionModel model)
単一の選択を扱うモデルオブジェクトを設定します。

パラメータ:
model - 新規 SingleSelectionModel
関連項目:
SingleSelectionModel

add

public JMenuItem add(JMenuItem menuItem)
指定されたメニュー項目をメニューの末尾に追加します。

パラメータ:
menuItem - 追加する JMenuitem
戻り値:
追加された JMenuItem

add

public JMenuItem add(String s)
指定されたテキストを持つ新しいメニュー項目を作成して、このメニューの末尾に追加します。

パラメータ:
s - 追加されるメニュー項目の文字列

add

public JMenuItem add(Action a)
メニューの末尾に、指定された Action オブジェクトを振り分けるメニュー項目を追加します。

パラメータ:
a - メニューに追加する Action
戻り値:
新しいメニュー項目
関連項目:
Action

createActionComponent

protected JMenuItem createActionComponent(Action a)
JPopupMenu に追加された ActionJMenuItem を作成するファクトリメソッドです。

パラメータ:
a - 追加されるメニュー項目の Action
戻り値:
新しいメニュー項目
導入されたバージョン:
1.3
関連項目:
Action

createActionChangeListener

protected PropertyChangeListener createActionChangeListener(JMenuItem b)
Action に対する変更が発生した場合にコントロールを更新する、適切に設定された PropertyChangeListener を返します。


remove

public void remove(int pos)
指定されたインデックスにあるコンポーネントをこのポップアップメニューから削除します。

オーバーライド:
クラス Container 内の remove
パラメータ:
pos - 削除される項目の位置
例外:
IllegalArgumentException - pos の値が 0 より小さいか、pos の値がメニュー項目の数より大きい場合
関連項目:
Container.add(java.awt.Component), Container.validate(), Container.getComponentCount()

setLightWeightPopupEnabled

public void setLightWeightPopupEnabled(boolean aFlag)
lightWeightPopupEnabled のデフォルト値を設定します。 デフォルトでは true です。Look & Feel がポップアップを表示するとき、デフォルトでは軽量 (すべて Java の) ポップアップの使用を選択できます。軽量ポップアップウィンドウは重量 (ネイティブピアの) ウィンドウより効率的ですが、軽量コンポーネントと重量コンポーネントを GUI の中で混在させてはいけません。アプリケーションで軽量コンポーネントと重量コンポーネントが混在している場合は、軽量ポップアップを無効にする必要があります。このプロパティーの値にかかわらず、常に重量ポップアップを使用する Look & Feel もあります。

パラメータ:
aFlag - 軽量ポップアップを無効にする場合は false
関連項目:
isLightWeightPopupEnabled()

isLightWeightPopupEnabled

public boolean isLightWeightPopupEnabled()
lightWeightPopupEnabled プロパティーを取得します。

戻り値:
lightWeightPopupEnabled プロパティーの値
関連項目:
setLightWeightPopupEnabled(boolean)

getLabel

public String getLabel()
ポップアップメニューのラベルを返します。

戻り値:
ポップアップメニューのラベルが格納されている文字列
関連項目:
setLabel(java.lang.String)

setLabel

public void setLabel(String label)
ポップアップメニューのラベルを設定します。Look & Feel の実装ごとに、ラベルを表示するかどうかを選択してもかまいません。

パラメータ:
label - ポップアップメニューのラベルを指定する文字列
関連項目:
setLabel(java.lang.String)

addSeparator

public void addSeparator()
メニューの末尾に新しいセパレータを追加します。


insert

public void insert(Action a,
                   int index)
指定された Action オブジェクトを、メニュー項目として指定の位置に挿入します。

パラメータ:
a - 挿入する Action オブジェクト
index - Action を挿入する位置。0 はメニューの先頭
例外:
IllegalArgumentException - index の値が 0 より小さい場合
関連項目:
Action

insert

public void insert(Component component,
                   int index)
指定されたコンポーネントを、メニューの指定された位置に挿入します。

パラメータ:
component - 挿入する Component
index - コンポーネントを挿入する位置。0 はメニューの先頭
例外:
IllegalArgumentException - index の値が 0 より小さい場合

addPopupMenuListener

public void addPopupMenuListener(PopupMenuListener l)
PopupMenu リスナーを追加します。

パラメータ:
l - 追加する PopupMenuListener

removePopupMenuListener

public void removePopupMenuListener(PopupMenuListener l)
PopupMenu リスナーを削除します。

パラメータ:
l - 削除する PopupMenuListener

getPopupMenuListeners

public PopupMenuListener[] getPopupMenuListeners()
この JMenuItem に addPopupMenuListener() で追加されたすべての PopupMenuListener の配列を返します。

戻り値:
追加されたすべての PopupMenuListener、リスナーが追加されていない場合は 空の配列
導入されたバージョン:
1.4

addMenuKeyListener

public void addMenuKeyListener(MenuKeyListener l)
ポップアップメニューに MenuKeyListener を追加します。

パラメータ:
l - 追加される MenuKeyListener
導入されたバージョン:
1.5

removeMenuKeyListener

public void removeMenuKeyListener(MenuKeyListener l)
ポップアップメニューから MenuKeyListener を削除します。

パラメータ:
l - 削除される MenuKeyListener
導入されたバージョン:
1.5

getMenuKeyListeners

public MenuKeyListener[] getMenuKeyListeners()
この JPopupMenu に addMenuKeyListener() で追加されたすべての MenuKeyListener の配列を返します。

戻り値:
追加されたすべての MenuKeyListener、リスナーが追加されていない場合は 空の配列
導入されたバージョン:
1.5

firePopupMenuWillBecomeVisible

protected void firePopupMenuWillBecomeVisible()
PopupMenuListener に、ポップアップメニューが可視になることを通知します。


firePopupMenuWillBecomeInvisible

protected void firePopupMenuWillBecomeInvisible()
PopupMenuListener に、ポップアップメニューが不可視になることを通知します。


firePopupMenuCanceled

protected void firePopupMenuCanceled()
PopupMenuListener に、ポップアップメニューが取り消されたことを通知します。


pack

public void pack()
コンテナをレイアウトして、内容の表示に最小限の空間を使用するようにします。


setVisible

public void setVisible(boolean b)
ポップアップメニューの可視性を設定します。

オーバーライド:
クラス JComponent 内の setVisible
パラメータ:
b - ポップアップを可視にする場合は true、隠す場合は false
関連項目:
Component.isVisible()

isVisible

public boolean isVisible()
ポップアップメニューが可視 (現在表示中) である場合に true を返します。

オーバーライド:
クラス Component 内の isVisible
戻り値:
コンポーネントが可視の場合は true、そうでない場合は false
関連項目:
Component.setVisible(boolean)

setLocation

public void setLocation(int x,
                        int y)
x、y 座標を使って、ポップアップメニューの左上隅の位置を設定します。

オーバーライド:
クラス Component 内の setLocation
パラメータ:
x - 画面の座標空間でのポップアップメニューの新しい位置の x 座標
y - 画面の座標空間でのポップアップメニューの新しい位置の y 座標
関連項目:
Component.getLocation(), Component.setBounds(int, int, int, int)

getInvoker

public Component getInvoker()
ポップアップメニューの呼び出しコンポーネントを返します。

戻り値:
ポップアップメニューが表示される Component

setInvoker

public void setInvoker(Component invoker)
ポップアップメニューの呼び出しコンポーネント、すなわち、ポップアップメニュー項目が表示されるコンポーネントを設定します。

パラメータ:
invoker - ポップアップメニューが表示される Component

show

public void show(Component invoker,
                 int x,
                 int y)
呼び出しコンポーネント内の x、y 座標で指定された位置に、ポップアップメニューを表示します。

パラメータ:
invoker - ポップアップメニューが表示されるコンポーネント
x - ポップアップメニューを表示する 呼び出しコンポーネントの座標空間での x 座標
y - ポップアップメニューを表示する 呼び出しコンポーネントの座標空間での y 座標

getComponentAtIndex

@Deprecated
public Component getComponentAtIndex(int i)
推奨されていません。 Container.getComponent(int) で置き換えられました。

指定されたインデックスの要素を返します。

パラメータ:
i - コンポーネントのインデックス。0 が先頭
戻り値:
指定されたインデックスの Component

getComponentIndex

public int getComponentIndex(Component c)
指定されたコンポーネントのインデックスを返します。

パラメータ:
c - 検索対象の Component
戻り値:
コンポーネントのインデックス。0 が先頭。コンポーネントがなければ -1

setPopupSize

public void setPopupSize(Dimension d)
Dimension オブジェクトを使用して、Popup ウィンドウのサイズを設定します。これは、setPreferredSize(d) と同等です。

パラメータ:
d - このコンポーネントの新規サイズを 指定する Dimension

setPopupSize

public void setPopupSize(int width,
                         int height)
ポップアップウィンドウのサイズを、指定された幅および高さに設定します。これは setPreferredSize(new Dimension(width, height)) に相当します。

パラメータ:
width - Popup の新しい幅 (ピクセル単位)
height - Popup の新しい高さ (ピクセル単位)

setSelected

public void setSelected(Component sel)
現在選択されるコンポーネントを設定します。結果として、選択モデルが変更されます。

パラメータ:
sel - 選択する Component

isBorderPainted

public boolean isBorderPainted()
ボーダーをペイントするかどうかを調べます。

戻り値:
ボーダーをペイントする場合は true、そうでない場合は false
関連項目:
setBorderPainted(boolean)

setBorderPainted

public void setBorderPainted(boolean b)
ボーダーをペイントするかどうかを設定します。

パラメータ:
b - true の場合はボーダーがペイントされる
関連項目:
isBorderPainted()

paintBorder

protected void paintBorder(Graphics g)
borderPainted プロパティーが true である場合に、ポップアップメニューのボーダーをペイントします。

オーバーライド:
クラス JComponent 内の paintBorder
パラメータ:
g - Graphics オブジェクト
関連項目:
JComponent.paint(java.awt.Graphics), JComponent.setBorder(javax.swing.border.Border)

getMargin

public Insets getMargin()
ポップアップメニューのボーダーと内容の間にあるマージンの値を返します (ピクセル単位)。

戻り値:
マージンの値を保持する Insets オブジェクト

paramString

protected String paramString()
この JPopupMenu の文字列表現を返します。このメソッドはデバッグ専用であり、返される文字列の内容および形式は実装によって異なります。返される文字列は空の場合がありますが、null にはなりません。

オーバーライド:
クラス JComponent 内の paramString
戻り値:
この JPopupMenu の文字列表現

getAccessibleContext

public AccessibleContext getAccessibleContext()
この JPopupMenu に関連した AccessibleContext を返します。JPopupMenu の場合、AccessibleContext は AccessibleJPopupMenu の形式を取ります。必要に応じて新規の AccessibleJPopupMenu インスタンスが作成されます。

定義:
インタフェース Accessible 内の getAccessibleContext
オーバーライド:
クラス JComponent 内の getAccessibleContext
戻り値:
この JPopupMenu の AccessibleContext として機能する AccessibleJPopupMenu

processMouseEvent

public void processMouseEvent(MouseEvent event,
                              MenuElement[] path,
                              MenuSelectionManager manager)
このメソッドは MenuElement インタフェースに適合するために必要ですが、実装されていません。

定義:
インタフェース MenuElement 内の processMouseEvent
関連項目:
MenuElement.processMouseEvent(MouseEvent, MenuElement[], MenuSelectionManager)

processKeyEvent

public void processKeyEvent(KeyEvent e,
                            MenuElement[] path,
                            MenuSelectionManager manager)
MenuSelectionManager から転送されるキーイベントを処理します。必要に応じて MenuSelectionManager の API を使用して、メニュー選択を変更します。

注: イベントをサブコンポーネントに転送する必要はありません。MenuSelectionManager が自動的に行います。

定義:
インタフェース MenuElement 内の processKeyEvent
パラメータ:
e - KeyEvent
path - MenuElement パス配列
manager - MenuSelectionManager

menuSelectionChanged

public void menuSelectionChanged(boolean isIncluded)
このメニューをアクティブにするか、アクティブではなくするためにメニューバーの選択が変更されたときに、メッセージを送ります。このメソッドは javax.swing.MenuElement インタフェースを実装します。MenuElement.menuSelectionChanged をオーバーライドしてください。

定義:
インタフェース MenuElement 内の menuSelectionChanged
パラメータ:
isIncluded - このメニューがアクティブな場合は true、 そうでない場合は false
関連項目:
MenuElement.menuSelectionChanged(boolean)

getSubElements

public MenuElement[] getSubElements()
このメニューコンポーネントのサブメニューを格納する MenuElement の配列を返します。JMenuElement インタフェースに適合する項目だけを返します。ポップアップメニューが null の場合は空の配列を返します。このメソッドは、MenuElement インタフェースに適合するために必要です。

定義:
インタフェース MenuElement 内の getSubElements
戻り値:
MenuElement オブジェクトの配列
関連項目:
MenuElement.getSubElements()

getComponent

public Component getComponent()
この JPopupMenu コンポーネントを返します。

定義:
インタフェース MenuElement 内の getComponent
戻り値:
この JPopupMenu オブジェクト
関連項目:
MenuElement.getComponent()

isPopupTrigger

public boolean isPopupTrigger(MouseEvent e)
JPopupMenu の現在インストールされている UI が MouseEvent をポップアップトリガーと見なす場合は、true を返します。

戻り値:
マウスイベントがポップアップトリガーの場合は true
導入されたバージョン:
1.3

JavaTM Platform
Standard Ed. 6

バグの報告と機能のリクエスト
さらに詳しい API リファレンスおよび開発者ドキュメントについては、Java SE 開発者用ドキュメントを参照してください。開発者向けの詳細な解説、概念の概要、用語の定義、バグの回避策、およびコード実例が含まれています。

Copyright 2009 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Documentation Redistribution Policy も参照してください。