< prev index next >
src/java.desktop/share/classes/javax/swing/JPopupMenu.java
Print this page
*** 47,60 ****
import java.applet.Applet;
/**
* An implementation of a popup menu -- a small window that pops up
! * and displays a series of choices. A <code>JPopupMenu</code> is used for the
* menu that appears when the user selects an item on the menu bar.
* It is also used for "pull-right" menu that appears when the
! * selects a menu item that activates it. Finally, a <code>JPopupMenu</code>
* can also be used anywhere else you want a menu to appear. For
* example, when the user right-clicks in a specified area.
* <p>
* For information and examples of using popup menus, see
* <a
--- 47,60 ----
import java.applet.Applet;
/**
* An implementation of a popup menu -- a small window that pops up
! * and displays a series of choices. A {@code JPopupMenu} is used for the
* menu that appears when the user selects an item on the menu bar.
* It is also used for "pull-right" menu that appears when the
! * selects a menu item that activates it. Finally, a {@code JPopupMenu}
* can also be used anywhere else you want a menu to appear. For
* example, when the user right-clicks in a specified area.
* <p>
* For information and examples of using popup menus, see
* <a
*** 70,80 ****
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans™
! * has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*
* @beaninfo
* attribute: isContainer false
* description: A small window that pops up and displays a series of choices.
--- 70,80 ----
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans™
! * has been added to the {@code java.beans} package.
* Please see {@link java.beans.XMLEncoder}.
*
* @beaninfo
* attribute: isContainer false
* description: A small window that pops up and displays a series of choices.
*** 137,164 ****
private static final boolean TRACE = false; // trace creates and disposes
private static final boolean VERBOSE = false; // show reuse hits/misses
private static final boolean DEBUG = false; // show bad params, misc.
/**
! * Sets the default value of the <code>lightWeightPopupEnabled</code>
* property.
*
! * @param aFlag <code>true</code> if popups can be lightweight,
! * otherwise <code>false</code>
* @see #getDefaultLightWeightPopupEnabled
* @see #setLightWeightPopupEnabled
*/
public static void setDefaultLightWeightPopupEnabled(boolean aFlag) {
SwingUtilities.appContextPut(defaultLWPopupEnabledKey,
Boolean.valueOf(aFlag));
}
/**
! * Gets the <code>defaultLightWeightPopupEnabled</code> property,
! * which by default is <code>true</code>.
*
! * @return the value of the <code>defaultLightWeightPopupEnabled</code>
* property
*
* @see #setDefaultLightWeightPopupEnabled
*/
public static boolean getDefaultLightWeightPopupEnabled() {
--- 137,164 ----
private static final boolean TRACE = false; // trace creates and disposes
private static final boolean VERBOSE = false; // show reuse hits/misses
private static final boolean DEBUG = false; // show bad params, misc.
/**
! * Sets the default value of the {@code lightWeightPopupEnabled}
* property.
*
! * @param aFlag {@code true} if popups can be lightweight,
! * otherwise {@code false}
* @see #getDefaultLightWeightPopupEnabled
* @see #setLightWeightPopupEnabled
*/
public static void setDefaultLightWeightPopupEnabled(boolean aFlag) {
SwingUtilities.appContextPut(defaultLWPopupEnabledKey,
Boolean.valueOf(aFlag));
}
/**
! * Gets the {@code defaultLightWeightPopupEnabled} property,
! * which by default is {@code true}.
*
! * @return the value of the {@code defaultLightWeightPopupEnabled}
* property
*
* @see #setDefaultLightWeightPopupEnabled
*/
public static boolean getDefaultLightWeightPopupEnabled() {
*** 171,188 ****
}
return b.booleanValue();
}
/**
! * Constructs a <code>JPopupMenu</code> without an "invoker".
*/
public JPopupMenu() {
this(null);
}
/**
! * Constructs a <code>JPopupMenu</code> with the specified title.
*
* @param label the string that a UI may use to display as a title
* for the popup menu.
*/
public JPopupMenu(String label) {
--- 171,188 ----
}
return b.booleanValue();
}
/**
! * Constructs a {@code JPopupMenu} without an "invoker".
*/
public JPopupMenu() {
this(null);
}
/**
! * Constructs a {@code JPopupMenu} with the specified title.
*
* @param label the string that a UI may use to display as a title
* for the popup menu.
*/
public JPopupMenu(String label) {
*** 197,216 ****
/**
* Returns the look and feel (L&F) object that renders this component.
*
! * @return the <code>PopupMenuUI</code> object that renders this component
*/
public PopupMenuUI getUI() {
return (PopupMenuUI)ui;
}
/**
* Sets the L&F object that renders this component.
*
! * @param ui the new <code>PopupMenuUI</code> L&F object
* @see UIDefaults#getUI
* @beaninfo
* bound: true
* hidden: true
* attribute: visualUpdate true
--- 197,216 ----
/**
* Returns the look and feel (L&F) object that renders this component.
*
! * @return the {@code PopupMenuUI} object that renders this component
*/
public PopupMenuUI getUI() {
return (PopupMenuUI)ui;
}
/**
* Sets the L&F object that renders this component.
*
! * @param ui the new {@code PopupMenuUI} L&F object
* @see UIDefaults#getUI
* @beaninfo
* bound: true
* hidden: true
* attribute: visualUpdate true
*** 260,280 ****
/**
* Returns the model object that handles single selections.
*
! * @return the <code>selectionModel</code> property
* @see SingleSelectionModel
*/
public SingleSelectionModel getSelectionModel() {
return selectionModel;
}
/**
* Sets the model object to handle single selections.
*
! * @param model the new <code>SingleSelectionModel</code>
* @see SingleSelectionModel
* @beaninfo
* description: The selection model for the popup menu
* expert: true
*/
--- 260,280 ----
/**
* Returns the model object that handles single selections.
*
! * @return the {@code selectionModel} property
* @see SingleSelectionModel
*/
public SingleSelectionModel getSelectionModel() {
return selectionModel;
}
/**
* Sets the model object to handle single selections.
*
! * @param model the new {@code SingleSelectionModel}
* @see SingleSelectionModel
* @beaninfo
* description: The selection model for the popup menu
* expert: true
*/
*** 283,294 ****
}
/**
* Appends the specified menu item to the end of this menu.
*
! * @param menuItem the <code>JMenuItem</code> to add
! * @return the <code>JMenuItem</code> added
*/
public JMenuItem add(JMenuItem menuItem) {
super.add(menuItem);
return menuItem;
}
--- 283,294 ----
}
/**
* Appends the specified menu item to the end of this menu.
*
! * @param menuItem the {@code JMenuItem} to add
! * @return the {@code JMenuItem} added
*/
public JMenuItem add(JMenuItem menuItem) {
super.add(menuItem);
return menuItem;
}
*** 304,316 ****
return add(new JMenuItem(s));
}
/**
* Appends a new menu item to the end of the menu which
! * dispatches the specified <code>Action</code> object.
*
! * @param a the <code>Action</code> to add to the menu
* @return the new menu item
* @see Action
*/
public JMenuItem add(Action a) {
JMenuItem mi = createActionComponent(a);
--- 304,316 ----
return add(new JMenuItem(s));
}
/**
* Appends a new menu item to the end of the menu which
! * dispatches the specified {@code Action} object.
*
! * @param a the {@code Action} to add to the menu
* @return the new menu item
* @see Action
*/
public JMenuItem add(Action a) {
JMenuItem mi = createActionComponent(a);
*** 424,437 ****
return result;
}
/**
! * Factory method which creates the <code>JMenuItem</code> for
! * <code>Actions</code> added to the <code>JPopupMenu</code>.
*
! * @param a the <code>Action</code> for the menu item to be added
* @return the new menu item
* @see Action
*
* @since 1.3
*/
--- 424,437 ----
return result;
}
/**
! * Factory method which creates the {@code JMenuItem} for
! * {@code Actions} added to the {@code JPopupMenu}.
*
! * @param a the {@code Action} for the menu item to be added
* @return the new menu item
* @see Action
*
* @since 1.3
*/
*** 449,460 ****
mi.setVerticalTextPosition(JButton.CENTER);
return mi;
}
/**
! * Returns a properly configured <code>PropertyChangeListener</code>
! * which updates the control as changes to the <code>Action</code> occur.
*
* @param b the menu item for which to create a listener
* @return a properly configured {@code PropertyChangeListener}
*/
protected PropertyChangeListener createActionChangeListener(JMenuItem b) {
--- 449,460 ----
mi.setVerticalTextPosition(JButton.CENTER);
return mi;
}
/**
! * Returns a properly configured {@code PropertyChangeListener}
! * which updates the control as changes to the {@code Action} occur.
*
* @param b the menu item for which to create a listener
* @return a properly configured {@code PropertyChangeListener}
*/
protected PropertyChangeListener createActionChangeListener(JMenuItem b) {
*** 464,475 ****
/**
* Removes the component at the specified index from this popup menu.
*
* @param pos the position of the item to be removed
* @exception IllegalArgumentException if the value of
! * <code>pos</code> < 0, or if the value of
! * <code>pos</code> is greater than the
* number of items
*/
public void remove(int pos) {
if (pos < 0) {
throw new IllegalArgumentException("index less than zero.");
--- 464,475 ----
/**
* Removes the component at the specified index from this popup menu.
*
* @param pos the position of the item to be removed
* @exception IllegalArgumentException if the value of
! * {@code pos < 0}, or if the value of
! * {@code pos} is greater than the
* number of items
*/
public void remove(int pos) {
if (pos < 0) {
throw new IllegalArgumentException("index less than zero.");
*** 479,490 ****
}
super.remove(pos);
}
/**
! * Sets the value of the <code>lightWeightPopupEnabled</code> property,
! * which by default is <code>true</code>.
* By default, when a look and feel displays a popup,
* it can choose to
* use a lightweight (all-Java) popup.
* Lightweight popup windows are more efficient than heavyweight
* (native peer) windows,
--- 479,490 ----
}
super.remove(pos);
}
/**
! * Sets the value of the {@code lightWeightPopupEnabled} property,
! * which by default is {@code true}.
* By default, when a look and feel displays a popup,
* it can choose to
* use a lightweight (all-Java) popup.
* Lightweight popup windows are more efficient than heavyweight
* (native peer) windows,
*** 492,502 ****
* If your application mixes lightweight and heavyweight components,
* you should disable lightweight popups.
* Some look and feels might always use heavyweight popups,
* no matter what the value of this property.
*
! * @param aFlag <code>false</code> to disable lightweight popups
* @beaninfo
* description: Determines whether lightweight popups are used when possible
* expert: true
*
* @see #isLightWeightPopupEnabled
--- 492,502 ----
* If your application mixes lightweight and heavyweight components,
* you should disable lightweight popups.
* Some look and feels might always use heavyweight popups,
* no matter what the value of this property.
*
! * @param aFlag {@code false} to disable lightweight popups
* @beaninfo
* description: Determines whether lightweight popups are used when possible
* expert: true
*
* @see #isLightWeightPopupEnabled
*** 506,518 ****
// this effected ALL JPopupMenus.
lightWeightPopup = aFlag;
}
/**
! * Gets the <code>lightWeightPopupEnabled</code> property.
*
! * @return the value of the <code>lightWeightPopupEnabled</code> property
* @see #setLightWeightPopupEnabled
*/
public boolean isLightWeightPopupEnabled() {
return lightWeightPopup;
}
--- 506,518 ----
// this effected ALL JPopupMenus.
lightWeightPopup = aFlag;
}
/**
! * Gets the {@code lightWeightPopupEnabled} property.
*
! * @return the value of the {@code lightWeightPopupEnabled} property
* @see #setLightWeightPopupEnabled
*/
public boolean isLightWeightPopupEnabled() {
return lightWeightPopup;
}
*** 557,573 ****
public void addSeparator() {
add( new JPopupMenu.Separator() );
}
/**
! * Inserts a menu item for the specified <code>Action</code> object at
* a given position.
*
! * @param a the <code>Action</code> object to insert
* @param index specifies the position at which to insert the
! * <code>Action</code>, where 0 is the first
! * @exception IllegalArgumentException if <code>index</code> < 0
* @see Action
*/
public void insert(Action a, int index) {
JMenuItem mi = createActionComponent(a);
mi.setAction(a);
--- 557,573 ----
public void addSeparator() {
add( new JPopupMenu.Separator() );
}
/**
! * Inserts a menu item for the specified {@code Action} object at
* a given position.
*
! * @param a the {@code Action} object to insert
* @param index specifies the position at which to insert the
! * {@code Action}, where 0 is the first
! * @exception IllegalArgumentException if {@code index < 0}
* @see Action
*/
public void insert(Action a, int index) {
JMenuItem mi = createActionComponent(a);
mi.setAction(a);
*** 576,589 ****
/**
* Inserts the specified component into the menu at a given
* position.
*
! * @param component the <code>Component</code> to insert
* @param index specifies the position at which
* to insert the component, where 0 is the first
! * @exception IllegalArgumentException if <code>index</code> < 0
*/
public void insert(Component component, int index) {
if (index < 0) {
throw new IllegalArgumentException("index less than zero.");
}
--- 576,589 ----
/**
* Inserts the specified component into the menu at a given
* position.
*
! * @param component the {@code Component} to insert
* @param index specifies the position at which
* to insert the component, where 0 is the first
! * @exception IllegalArgumentException if {@code index < 0}
*/
public void insert(Component component, int index) {
if (index < 0) {
throw new IllegalArgumentException("index less than zero.");
}
*** 610,682 ****
add(tempItem);
}
}
/**
! * Adds a <code>PopupMenu</code> listener.
*
! * @param l the <code>PopupMenuListener</code> to add
*/
public void addPopupMenuListener(PopupMenuListener l) {
listenerList.add(PopupMenuListener.class,l);
}
/**
! * Removes a <code>PopupMenu</code> listener.
*
! * @param l the <code>PopupMenuListener</code> to remove
*/
public void removePopupMenuListener(PopupMenuListener l) {
listenerList.remove(PopupMenuListener.class,l);
}
/**
! * Returns an array of all the <code>PopupMenuListener</code>s added
* to this JMenuItem with addPopupMenuListener().
*
! * @return all of the <code>PopupMenuListener</code>s added or an empty
* array if no listeners have been added
* @since 1.4
*/
public PopupMenuListener[] getPopupMenuListeners() {
return listenerList.getListeners(PopupMenuListener.class);
}
/**
! * Adds a <code>MenuKeyListener</code> to the popup menu.
*
! * @param l the <code>MenuKeyListener</code> to be added
* @since 1.5
*/
public void addMenuKeyListener(MenuKeyListener l) {
listenerList.add(MenuKeyListener.class, l);
}
/**
! * Removes a <code>MenuKeyListener</code> from the popup menu.
*
! * @param l the <code>MenuKeyListener</code> to be removed
* @since 1.5
*/
public void removeMenuKeyListener(MenuKeyListener l) {
listenerList.remove(MenuKeyListener.class, l);
}
/**
! * Returns an array of all the <code>MenuKeyListener</code>s added
* to this JPopupMenu with addMenuKeyListener().
*
! * @return all of the <code>MenuKeyListener</code>s added or an empty
* array if no listeners have been added
* @since 1.5
*/
public MenuKeyListener[] getMenuKeyListeners() {
return listenerList.getListeners(MenuKeyListener.class);
}
/**
! * Notifies <code>PopupMenuListener</code>s that this popup menu will
* become visible.
*/
protected void firePopupMenuWillBecomeVisible() {
Object[] listeners = listenerList.getListenerList();
PopupMenuEvent e=null;
--- 610,682 ----
add(tempItem);
}
}
/**
! * Adds a {@code PopupMenu} listener.
*
! * @param l the {@code PopupMenuListener} to add
*/
public void addPopupMenuListener(PopupMenuListener l) {
listenerList.add(PopupMenuListener.class,l);
}
/**
! * Removes a {@code PopupMenu} listener.
*
! * @param l the {@code PopupMenuListener} to remove
*/
public void removePopupMenuListener(PopupMenuListener l) {
listenerList.remove(PopupMenuListener.class,l);
}
/**
! * Returns an array of all the {@code PopupMenuListener}s added
* to this JMenuItem with addPopupMenuListener().
*
! * @return all of the {@code PopupMenuListener}s added or an empty
* array if no listeners have been added
* @since 1.4
*/
public PopupMenuListener[] getPopupMenuListeners() {
return listenerList.getListeners(PopupMenuListener.class);
}
/**
! * Adds a {@code MenuKeyListener} to the popup menu.
*
! * @param l the {@code MenuKeyListener} to be added
* @since 1.5
*/
public void addMenuKeyListener(MenuKeyListener l) {
listenerList.add(MenuKeyListener.class, l);
}
/**
! * Removes a {@code MenuKeyListener} from the popup menu.
*
! * @param l the {@code MenuKeyListener} to be removed
* @since 1.5
*/
public void removeMenuKeyListener(MenuKeyListener l) {
listenerList.remove(MenuKeyListener.class, l);
}
/**
! * Returns an array of all the {@code MenuKeyListener}s added
* to this JPopupMenu with addMenuKeyListener().
*
! * @return all of the {@code MenuKeyListener}s added or an empty
* array if no listeners have been added
* @since 1.5
*/
public MenuKeyListener[] getMenuKeyListeners() {
return listenerList.getListeners(MenuKeyListener.class);
}
/**
! * Notifies {@code PopupMenuListener}s that this popup menu will
* become visible.
*/
protected void firePopupMenuWillBecomeVisible() {
Object[] listeners = listenerList.getListenerList();
PopupMenuEvent e=null;
*** 688,698 ****
}
}
}
/**
! * Notifies <code>PopupMenuListener</code>s that this popup menu will
* become invisible.
*/
protected void firePopupMenuWillBecomeInvisible() {
Object[] listeners = listenerList.getListenerList();
PopupMenuEvent e=null;
--- 688,698 ----
}
}
}
/**
! * Notifies {@code PopupMenuListener}s that this popup menu will
* become invisible.
*/
protected void firePopupMenuWillBecomeInvisible() {
Object[] listeners = listenerList.getListenerList();
PopupMenuEvent e=null;
*** 704,714 ****
}
}
}
/**
! * Notifies <code>PopupMenuListeners</code> that this popup menu is
* cancelled.
*/
protected void firePopupMenuCanceled() {
Object[] listeners = listenerList.getListenerList();
PopupMenuEvent e=null;
--- 704,714 ----
}
}
}
/**
! * Notifies {@code PopupMenuListeners} that this popup menu is
* cancelled.
*/
protected void firePopupMenuCanceled() {
Object[] listeners = listenerList.getListenerList();
PopupMenuEvent e=null;
*** 808,822 ****
}
}
}
/**
! * Retrieves <code>Popup</code> instance from the
! * <code>PopupMenuUI</code> that has had <code>show</code> invoked on
! * it. If the current <code>popup</code> is non-null,
! * this will invoke <code>dispose</code> of it, and then
! * <code>show</code> the new one.
* <p>
* This does NOT fire any events, it is up the caller to dispatch
* the necessary events.
*/
private void showPopup() {
--- 808,822 ----
}
}
}
/**
! * Retrieves {@code Popup} instance from the
! * {@code PopupMenuUI} that has had {@code show} invoked on
! * it. If the current {@code popup} is non-null,
! * this will invoke {@code dispose} of it, and then
! * {@code show} the new one.
* <p>
* This does NOT fire any events, it is up the caller to dispatch
* the necessary events.
*/
private void showPopup() {
*** 882,892 ****
}
}
/**
* Returns true if the popup menu is a standalone popup menu
! * rather than the submenu of a <code>JMenu</code>.
*
* @return true if this menu is a standalone popup menu, otherwise false
*/
private boolean isPopupMenu() {
return ((invoker != null) && !(invoker instanceof JMenu));
--- 882,892 ----
}
}
/**
* Returns true if the popup menu is a standalone popup menu
! * rather than the submenu of a {@code JMenu}.
*
* @return true if this menu is a standalone popup menu, otherwise false
*/
private boolean isPopupMenu() {
return ((invoker != null) && !(invoker instanceof JMenu));
*** 894,914 ****
/**
* Returns the component which is the 'invoker' of this
* popup menu.
*
! * @return the <code>Component</code> in which the popup menu is displayed
*/
public Component getInvoker() {
return this.invoker;
}
/**
* Sets the invoker of this popup menu -- the component in which
* the popup menu menu is to be displayed.
*
! * @param invoker the <code>Component</code> in which the popup
* menu is displayed
* @beaninfo
* description: The invoking component for the popup menu
* expert: true
*/
--- 894,914 ----
/**
* Returns the component which is the 'invoker' of this
* popup menu.
*
! * @return the {@code Component} in which the popup menu is displayed
*/
public Component getInvoker() {
return this.invoker;
}
/**
* Sets the invoker of this popup menu -- the component in which
* the popup menu menu is to be displayed.
*
! * @param invoker the {@code Component} in which the popup
* menu is displayed
* @beaninfo
* description: The invoking component for the popup menu
* expert: true
*/
*** 972,982 ****
/**
* Returns the popup menu which is at the root of the menu system
* for this popup menu.
*
! * @return the topmost grandparent <code>JPopupMenu</code>
*/
JPopupMenu getRootPopupMenu() {
JPopupMenu mp = this;
while((mp!=null) && (mp.isPopupMenu()!=true) &&
(mp.getInvoker() != null) &&
--- 972,982 ----
/**
* Returns the popup menu which is at the root of the menu system
* for this popup menu.
*
! * @return the topmost grandparent {@code JPopupMenu}
*/
JPopupMenu getRootPopupMenu() {
JPopupMenu mp = this;
while((mp!=null) && (mp.isPopupMenu()!=true) &&
(mp.getInvoker() != null) &&
*** 990,1011 ****
/**
* Returns the component at the specified index.
*
* @param i the index of the component, where 0 is the first
! * @return the <code>Component</code> at that index
* @deprecated replaced by {@link java.awt.Container#getComponent(int)}
*/
@Deprecated
public Component getComponentAtIndex(int i) {
return getComponent(i);
}
/**
* Returns the index of the specified component.
*
! * @param c the <code>Component</code> to find
* @return the index of the component, where 0 is the first;
* or -1 if the component is not found
*/
public int getComponentIndex(Component c) {
int ncomponents = this.getComponentCount();
--- 990,1011 ----
/**
* Returns the component at the specified index.
*
* @param i the index of the component, where 0 is the first
! * @return the {@code Component} at that index
* @deprecated replaced by {@link java.awt.Container#getComponent(int)}
*/
@Deprecated
public Component getComponentAtIndex(int i) {
return getComponent(i);
}
/**
* Returns the index of the specified component.
*
! * @param c the {@code Component} to find
* @return the index of the component, where 0 is the first;
* or -1 if the component is not found
*/
public int getComponentIndex(Component c) {
int ncomponents = this.getComponentCount();
*** 1017,1030 ****
}
return -1;
}
/**
! * Sets the size of the Popup window using a <code>Dimension</code> object.
! * This is equivalent to <code>setPreferredSize(d)</code>.
*
! * @param d the <code>Dimension</code> specifying the new size
* of this component.
* @beaninfo
* description: The size of the popup menu
*/
public void setPopupSize(Dimension d) {
--- 1017,1030 ----
}
return -1;
}
/**
! * Sets the size of the Popup window using a {@code Dimension} object.
! * This is equivalent to {@code setPreferredSize(d)}.
*
! * @param d the {@code Dimension} specifying the new size
* of this component.
* @beaninfo
* description: The size of the popup menu
*/
public void setPopupSize(Dimension d) {
*** 1041,1051 ****
}
/**
* Sets the size of the Popup window to the specified width and
* height. This is equivalent to
! * <code>setPreferredSize(new Dimension(width, height))</code>.
*
* @param width the new width of the Popup in pixels
* @param height the new height of the Popup in pixels
* @beaninfo
* description: The size of the popup menu
--- 1041,1051 ----
}
/**
* Sets the size of the Popup window to the specified width and
* height. This is equivalent to
! * {@code setPreferredSize(new Dimension(width, height))}.
*
* @param width the new width of the Popup in pixels
* @param height the new height of the Popup in pixels
* @beaninfo
* description: The size of the popup menu
*** 1056,1066 ****
/**
* Sets the currently selected component, This will result
* in a change to the selection model.
*
! * @param sel the <code>Component</code> to select
* @beaninfo
* description: The selected component on the popup menu
* expert: true
* hidden: true
*/
--- 1056,1066 ----
/**
* Sets the currently selected component, This will result
* in a change to the selection model.
*
! * @param sel the {@code Component} to select
* @beaninfo
* description: The selected component on the popup menu
* expert: true
* hidden: true
*/
*** 1092,1104 ****
paintBorder = b;
repaint();
}
/**
! * Paints the popup menu's border if the <code>borderPainted</code>
! * property is <code>true</code>.
! * @param g the <code>Graphics</code> object
*
* @see JComponent#paint
* @see JComponent#setBorder
*/
protected void paintBorder(Graphics g) {
--- 1092,1104 ----
paintBorder = b;
repaint();
}
/**
! * Paints the popup menu's border if the {@code borderPainted}
! * property is {@code true}.
! * @param g the {@code Graphics} object
*
* @see JComponent#paint
* @see JComponent#setBorder
*/
protected void paintBorder(Graphics g) {
*** 1109,1119 ****
/**
* Returns the margin, in pixels, between the popup menu's border and
* its containers.
*
! * @return an <code>Insets</code> object containing the margin values.
*/
public Insets getMargin() {
if(margin == null) {
return new Insets(0,0,0,0);
} else {
--- 1109,1119 ----
/**
* Returns the margin, in pixels, between the popup menu's border and
* its containers.
*
! * @return an {@code Insets} object containing the margin values.
*/
public Insets getMargin() {
if(margin == null) {
return new Insets(0,0,0,0);
} else {
*** 1122,1135 ****
}
/**
* Examines the list of menu items to determine whether
! * <code>popup</code> is a popup menu.
*
! * @param popup a <code>JPopupMenu</code>
! * @return true if <code>popup</code>
*/
boolean isSubPopupMenu(JPopupMenu popup) {
int ncomponents = this.getComponentCount();
Component[] component = this.getComponents();
for (int i = 0 ; i < ncomponents ; i++) {
--- 1122,1135 ----
}
/**
* Examines the list of menu items to determine whether
! * {@code popup} is a popup menu.
*
! * @param popup a {@code JPopupMenu}
! * @return true if {@code popup}
*/
boolean isSubPopupMenu(JPopupMenu popup) {
int ncomponents = this.getComponentCount();
Component[] component = this.getComponents();
for (int i = 0 ; i < ncomponents ; i++) {
*** 1156,1173 ****
return (Frame)w;
}
/**
! * Returns a string representation of this <code>JPopupMenu</code>.
* This method
* is intended to be used only for debugging purposes, and the
* content and format of the returned string may vary between
* implementations. The returned string may be empty but may not
! * be <code>null</code>.
*
! * @return a string representation of this <code>JPopupMenu</code>.
*/
protected String paramString() {
String labelString = (label != null ?
label : "");
String paintBorderString = (paintBorder ?
--- 1156,1173 ----
return (Frame)w;
}
/**
! * Returns a string representation of this {@code JPopupMenu}.
* This method
* is intended to be used only for debugging purposes, and the
* content and format of the returned string may vary between
* implementations. The returned string may be empty but may not
! * be {@code null}.
*
! * @return a string representation of this {@code JPopupMenu}.
*/
protected String paramString() {
String labelString = (label != null ?
label : "");
String paintBorderString = (paintBorder ?
*** 1205,1215 ****
return accessibleContext;
}
/**
* This class implements accessibility support for the
! * <code>JPopupMenu</code> class. It provides an implementation of the
* Java Accessibility API appropriate to popup menu user-interface
* elements.
*/
@SuppressWarnings("serial")
protected class AccessibleJPopupMenu extends AccessibleJComponent
--- 1205,1215 ----
return accessibleContext;
}
/**
* This class implements accessibility support for the
! * {@code JPopupMenu} class. It provides an implementation of the
* Java Accessibility API appropriate to popup menu user-interface
* elements.
*/
@SuppressWarnings("serial")
protected class AccessibleJPopupMenu extends AccessibleJComponent
*** 1234,1244 ****
return AccessibleRole.POPUP_MENU;
}
/**
* This method gets called when a bound property is changed.
! * @param e A <code>PropertyChangeEvent</code> object describing
* the event source and the property that has changed. Must not be null.
*
* @throws NullPointerException if the parameter is null.
* @since 1.5
*/
--- 1234,1244 ----
return AccessibleRole.POPUP_MENU;
}
/**
* This method gets called when a bound property is changed.
! * @param e A {@code PropertyChangeEvent} object describing
* the event source and the property that has changed. Must not be null.
*
* @throws NullPointerException if the parameter is null.
* @since 1.5
*/
*** 1377,1402 ****
}
/**
* This method is required to conform to the
! * <code>MenuElement</code> interface, but it not implemented.
* @see MenuElement#processMouseEvent(MouseEvent, MenuElement[], MenuSelectionManager)
*/
public void processMouseEvent(MouseEvent event,MenuElement path[],MenuSelectionManager manager) {}
/**
* Processes a key event forwarded from the
! * <code>MenuSelectionManager</code> and changes the menu selection,
! * if necessary, by using <code>MenuSelectionManager</code>'s API.
* <p>
* Note: you do not have to forward the event to sub-components.
! * This is done automatically by the <code>MenuSelectionManager</code>.
*
! * @param e a <code>KeyEvent</code>
! * @param path the <code>MenuElement</code> path array
! * @param manager the <code>MenuSelectionManager</code>
*/
public void processKeyEvent(KeyEvent e, MenuElement path[],
MenuSelectionManager manager) {
MenuKeyEvent mke = new MenuKeyEvent(e.getComponent(), e.getID(),
e.getWhen(), e.getModifiers(),
--- 1377,1402 ----
}
/**
* This method is required to conform to the
! * {@code MenuElement} interface, but it not implemented.
* @see MenuElement#processMouseEvent(MouseEvent, MenuElement[], MenuSelectionManager)
*/
public void processMouseEvent(MouseEvent event,MenuElement path[],MenuSelectionManager manager) {}
/**
* Processes a key event forwarded from the
! * {@code MenuSelectionManager} and changes the menu selection,
! * if necessary, by using {@code MenuSelectionManager}'s API.
* <p>
* Note: you do not have to forward the event to sub-components.
! * This is done automatically by the {@code MenuSelectionManager}.
*
! * @param e a {@code KeyEvent}
! * @param path the {@code MenuElement} path array
! * @param manager the {@code MenuSelectionManager}
*/
public void processKeyEvent(KeyEvent e, MenuElement path[],
MenuSelectionManager manager) {
MenuKeyEvent mke = new MenuKeyEvent(e.getComponent(), e.getID(),
e.getWhen(), e.getModifiers(),
*** 1410,1420 ****
}
/**
* Handles a keystroke in a menu.
*
! * @param e a <code>MenuKeyEvent</code> object
* @since 1.5
*/
private void processMenuKeyEvent(MenuKeyEvent e) {
switch (e.getID()) {
case KeyEvent.KEY_PRESSED:
--- 1410,1420 ----
}
/**
* Handles a keystroke in a menu.
*
! * @param e a {@code MenuKeyEvent} object
* @since 1.5
*/
private void processMenuKeyEvent(MenuKeyEvent e) {
switch (e.getID()) {
case KeyEvent.KEY_PRESSED:
*** 1430,1440 ****
/**
* Notifies all listeners that have registered interest for
* notification on this event type.
*
! * @param event a <code>MenuKeyEvent</code>
* @see EventListenerList
*/
private void fireMenuKeyPressed(MenuKeyEvent event) {
Object[] listeners = listenerList.getListenerList();
for (int i = listeners.length-2; i>=0; i-=2) {
--- 1430,1440 ----
/**
* Notifies all listeners that have registered interest for
* notification on this event type.
*
! * @param event a {@code MenuKeyEvent}
* @see EventListenerList
*/
private void fireMenuKeyPressed(MenuKeyEvent event) {
Object[] listeners = listenerList.getListenerList();
for (int i = listeners.length-2; i>=0; i-=2) {
*** 1446,1456 ****
/**
* Notifies all listeners that have registered interest for
* notification on this event type.
*
! * @param event a <code>MenuKeyEvent</code>
* @see EventListenerList
*/
private void fireMenuKeyReleased(MenuKeyEvent event) {
Object[] listeners = listenerList.getListenerList();
for (int i = listeners.length-2; i>=0; i-=2) {
--- 1446,1456 ----
/**
* Notifies all listeners that have registered interest for
* notification on this event type.
*
! * @param event a {@code MenuKeyEvent}
* @see EventListenerList
*/
private void fireMenuKeyReleased(MenuKeyEvent event) {
Object[] listeners = listenerList.getListenerList();
for (int i = listeners.length-2; i>=0; i-=2) {
*** 1462,1472 ****
/**
* Notifies all listeners that have registered interest for
* notification on this event type.
*
! * @param event a <code>MenuKeyEvent</code>
* @see EventListenerList
*/
private void fireMenuKeyTyped(MenuKeyEvent event) {
Object[] listeners = listenerList.getListenerList();
for (int i = listeners.length-2; i>=0; i-=2) {
--- 1462,1472 ----
/**
* Notifies all listeners that have registered interest for
* notification on this event type.
*
! * @param event a {@code MenuKeyEvent}
* @see EventListenerList
*/
private void fireMenuKeyTyped(MenuKeyEvent event) {
Object[] listeners = listenerList.getListenerList();
for (int i = listeners.length-2; i>=0; i-=2) {
*** 1477,1488 ****
}
/**
* Messaged when the menubar selection changes to activate or
* deactivate this menu. This implements the
! * <code>javax.swing.MenuElement</code> interface.
! * Overrides <code>MenuElement.menuSelectionChanged</code>.
*
* @param isIncluded true if this menu is active, false if
* it is not
* @see MenuElement#menuSelectionChanged(boolean)
*/
--- 1477,1488 ----
}
/**
* Messaged when the menubar selection changes to activate or
* deactivate this menu. This implements the
! * {@code javax.swing.MenuElement} interface.
! * Overrides {@code MenuElement.menuSelectionChanged}.
*
* @param isIncluded true if this menu is active, false if
* it is not
* @see MenuElement#menuSelectionChanged(boolean)
*/
*** 1500,1517 ****
if (isPopupMenu() && !isIncluded)
setVisible(false);
}
/**
! * Returns an array of <code>MenuElement</code>s containing the submenu
* for this menu component. It will only return items conforming to
! * the <code>JMenuElement</code> interface.
! * If popup menu is <code>null</code> returns
* an empty array. This method is required to conform to the
! * <code>MenuElement</code> interface.
*
! * @return an array of <code>MenuElement</code> objects
* @see MenuElement#getSubElements
*/
public MenuElement[] getSubElements() {
MenuElement result[];
Vector<MenuElement> tmp = new Vector<MenuElement>();
--- 1500,1517 ----
if (isPopupMenu() && !isIncluded)
setVisible(false);
}
/**
! * Returns an array of {@code MenuElement}s containing the submenu
* for this menu component. It will only return items conforming to
! * the {@code JMenuElement} interface.
! * If popup menu is {@code null} returns
* an empty array. This method is required to conform to the
! * {@code MenuElement} interface.
*
! * @return an array of {@code MenuElement} objects
* @see MenuElement#getSubElements
*/
public MenuElement[] getSubElements() {
MenuElement result[];
Vector<MenuElement> tmp = new Vector<MenuElement>();
*** 1530,1541 ****
result[i] = tmp.elementAt(i);
return result;
}
/**
! * Returns this <code>JPopupMenu</code> component.
! * @return this <code>JPopupMenu</code> object
* @see MenuElement#getComponent
*/
public Component getComponent() {
return this;
}
--- 1530,1541 ----
result[i] = tmp.elementAt(i);
return result;
}
/**
! * Returns this {@code JPopupMenu} component.
! * @return this {@code JPopupMenu} object
* @see MenuElement#getComponent
*/
public Component getComponent() {
return this;
}
*** 1568,1579 ****
}
}
/**
! * Returns true if the <code>MouseEvent</code> is considered a popup trigger
! * by the <code>JPopupMenu</code>'s currently installed UI.
*
* @param e a {@code MouseEvent}
* @return true if the mouse event is a popup trigger
* @since 1.3
*/
--- 1568,1579 ----
}
}
/**
! * Returns true if the {@code MouseEvent} is considered a popup trigger
! * by the {@code JPopupMenu}'s currently installed UI.
*
* @param e a {@code MouseEvent}
* @return true if the mouse event is a popup trigger
* @since 1.3
*/
< prev index next >