< prev index next >

src/java.desktop/share/classes/javax/swing/JMenu.java

Print this page

        

*** 57,82 **** import java.lang.ref.WeakReference; /** * An implementation of a menu -- a popup window containing ! * <code>JMenuItem</code>s that ! * is displayed when the user selects an item on the <code>JMenuBar</code>. ! * In addition to <code>JMenuItem</code>s, a <code>JMenu</code> can ! * also contain <code>JSeparator</code>s. * <p> ! * In essence, a menu is a button with an associated <code>JPopupMenu</code>. ! * When the "button" is pressed, the <code>JPopupMenu</code> appears. If the ! * "button" is on the <code>JMenuBar</code>, the menu is a top-level window. ! * If the "button" is another menu item, then the <code>JPopupMenu</code> is * "pull-right" menu. * <p> * Menus can be configured, and to some degree controlled, by * <code><a href="Action.html">Action</a></code>s. Using an ! * <code>Action</code> with a menu has many benefits beyond directly * configuring a menu. Refer to <a href="Action.html#buttonActions"> ! * Swing Components Supporting <code>Action</code></a> for more * details, and you can find more information in <a * href="http://docs.oracle.com/javase/tutorial/uiswing/misc/action.html">How * to Use Actions</a>, a section in <em>The Java Tutorial</em>. * <p> * For information and examples of using menus see --- 57,82 ---- import java.lang.ref.WeakReference; /** * An implementation of a menu -- a popup window containing ! * {@code JMenuItem}s that ! * is displayed when the user selects an item on the {@code JMenuBar}. ! * In addition to {@code JMenuItem}s, a {@code JMenu} can ! * also contain {@code JSeparator}s. * <p> ! * In essence, a menu is a button with an associated {@code JPopupMenu}. ! * When the "button" is pressed, the {@code JPopupMenu} appears. If the ! * "button" is on the {@code JMenuBar}, the menu is a top-level window. ! * If the "button" is another menu item, then the {@code JPopupMenu} is * "pull-right" menu. * <p> * Menus can be configured, and to some degree controlled, by * <code><a href="Action.html">Action</a></code>s. Using an ! * {@code Action} with a menu has many benefits beyond directly * configuring a menu. Refer to <a href="Action.html#buttonActions"> ! * Swing Components Supporting {@code Action}</a> for more * details, and you can find more information in <a * href="http://docs.oracle.com/javase/tutorial/uiswing/misc/action.html">How * to Use Actions</a>, a section in <em>The Java Tutorial</em>. * <p> * For information and examples of using menus see
*** 92,102 **** * 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&trade; ! * has been added to the <code>java.beans</code> package. * Please see {@link java.beans.XMLEncoder}. * * @beaninfo * attribute: isContainer true * description: A popup window containing menu items displayed in a menu bar. --- 92,102 ---- * 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&trade; ! * has been added to the {@code java.beans} package. * Please see {@link java.beans.XMLEncoder}. * * @beaninfo * attribute: isContainer true * description: A popup window containing menu items displayed in a menu bar.
*** 123,191 **** * The popup menu portion of the menu. */ private JPopupMenu popupMenu; /* ! * The button's model listeners. Default is <code>null</code>. */ private ChangeListener menuChangeListener = null; /* ! * Only one <code>MenuEvent</code> is needed for each menu since the * event's only state is the source property. The source of events ! * generated is always "this". Default is <code>null</code>. */ private MenuEvent menuEvent = null; /* * Used by the look and feel (L&F) code to handle * implementation specific menu behaviors. */ private int delay; /* ! * Location of the popup component. Location is <code>null</code> ! * if it was not customized by <code>setMenuLocation</code> */ private Point customMenuLocation = null; /* Diagnostic aids -- should be false for production builds. */ 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. /** ! * Constructs a new <code>JMenu</code> with no text. */ public JMenu() { this(""); } /** ! * Constructs a new <code>JMenu</code> with the supplied string * as its text. * * @param s the text for the menu label */ public JMenu(String s) { super(s); } /** * Constructs a menu whose properties are taken from the ! * <code>Action</code> supplied. ! * @param a an <code>Action</code> * * @since 1.3 */ public JMenu(Action a) { this(); setAction(a); } /** ! * Constructs a new <code>JMenu</code> with the supplied string as * its text and specified as a tear-off menu or not. * * @param s the text for the menu label * @param b can the menu be torn off (not yet implemented) */ --- 123,191 ---- * The popup menu portion of the menu. */ private JPopupMenu popupMenu; /* ! * The button's model listeners. Default is {@code null}. */ private ChangeListener menuChangeListener = null; /* ! * Only one {@code MenuEvent} is needed for each menu since the * event's only state is the source property. The source of events ! * generated is always "this". Default is {@code null}. */ private MenuEvent menuEvent = null; /* * Used by the look and feel (L&F) code to handle * implementation specific menu behaviors. */ private int delay; /* ! * Location of the popup component. Location is {@code null} ! * if it was not customized by {@code setMenuLocation} */ private Point customMenuLocation = null; /* Diagnostic aids -- should be false for production builds. */ 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. /** ! * Constructs a new {@code JMenu} with no text. */ public JMenu() { this(""); } /** ! * Constructs a new {@code JMenu} with the supplied string * as its text. * * @param s the text for the menu label */ public JMenu(String s) { super(s); } /** * Constructs a menu whose properties are taken from the ! * {@code Action} supplied. ! * @param a an {@code Action} * * @since 1.3 */ public JMenu(Action a) { this(); setAction(a); } /** ! * Constructs a new {@code JMenu} with the supplied string as * its text and specified as a tear-off menu or not. * * @param s the text for the menu label * @param b can the menu be torn off (not yet implemented) */
*** 194,210 **** } /** * Overriden to do nothing. We want JMenu to be focusable, but ! * <code>JMenuItem</code> doesn't want to be, thus we override this ! * do nothing. We don't invoke <code>setFocusable(true)</code> after * super's constructor has completed as this has the side effect that ! * <code>JMenu</code> will be considered traversable via the * keyboard, which we don't want. Making a Component traversable by ! * the keyboard after invoking <code>setFocusable(true)</code> is OK, ! * as <code>setFocusable</code> is new API * and is speced as such, but internally we don't want to use it like * this else we change the keyboard traversability. */ void initFocusability() { } --- 194,210 ---- } /** * Overriden to do nothing. We want JMenu to be focusable, but ! * {@code JMenuItem} doesn't want to be, thus we override this ! * do nothing. We don't invoke {@code setFocusable(true)} after * super's constructor has completed as this has the side effect that ! * {@code JMenu} will be considered traversable via the * keyboard, which we don't want. Making a Component traversable by ! * the keyboard after invoking {@code setFocusable(true)} is OK, ! * as {@code setFocusable} is new API * and is speced as such, but internally we don't want to use it like * this else we change the keyboard traversability. */ void initFocusability() { }
*** 243,253 **** /** * Sets the data model for the "menu button" -- the label * that the user clicks to open or close the menu. * ! * @param newModel the <code>ButtonModel</code> * @see #getModel * @beaninfo * description: The menu's model * bound: true * expert: true --- 243,253 ---- /** * Sets the data model for the "menu button" -- the label * that the user clicks to open or close the menu. * ! * @param newModel the {@code ButtonModel} * @see #getModel * @beaninfo * description: The menu's model * bound: true * expert: true
*** 349,369 **** } } } /** ! * Computes the origin for the <code>JMenu</code>'s popup menu. * This method uses Look and Feel properties named ! * <code>Menu.menuPopupOffsetX</code>, ! * <code>Menu.menuPopupOffsetY</code>, ! * <code>Menu.submenuPopupOffsetX</code>, and ! * <code>Menu.submenuPopupOffsetY</code> * to adjust the exact location of popup. * ! * @return a <code>Point</code> in the coordinate space of the * menu which should be used as the origin ! * of the <code>JMenu</code>'s popup menu * * @since 1.3 */ protected Point getPopupMenuOrigin() { int x; --- 349,369 ---- } } } /** ! * Computes the origin for the {@code JMenu}'s popup menu. * This method uses Look and Feel properties named ! * {@code Menu.menuPopupOffsetX}, ! * {@code Menu.menuPopupOffsetY}, ! * {@code Menu.submenuPopupOffsetX}, and ! * {@code Menu.submenuPopupOffsetY} * to adjust the exact location of popup. * ! * @return a {@code Point} in the coordinate space of the * menu which should be used as the origin ! * of the {@code JMenu}'s popup menu * * @since 1.3 */ protected Point getPopupMenuOrigin() { int x;
*** 491,523 **** /** * Returns the suggested delay, in milliseconds, before submenus * are popped up or down. * Each look and feel (L&amp;F) may determine its own policy for ! * observing the <code>delay</code> property. * In most cases, the delay is not observed for top level menus ! * or while dragging. The default for <code>delay</code> is 0. * This method is a property of the look and feel code and is used * to manage the idiosyncrasies of the various UI implementations. * * ! * @return the <code>delay</code> property */ public int getDelay() { return delay; } /** ! * Sets the suggested delay before the menu's <code>PopupMenu</code> * is popped up or down. Each look and feel (L&amp;F) may determine * it's own policy for observing the delay property. In most cases, * the delay is not observed for top level menus or while dragging. * This method is a property of the look and feel code and is used * to manage the idiosyncrasies of the various UI implementations. * * @param d the number of milliseconds to delay ! * @exception IllegalArgumentException if <code>d</code> * is less than 0 * @beaninfo * description: The delay between menu selection and making the popup menu visible * expert: true */ --- 491,523 ---- /** * Returns the suggested delay, in milliseconds, before submenus * are popped up or down. * Each look and feel (L&amp;F) may determine its own policy for ! * observing the {@code delay} property. * In most cases, the delay is not observed for top level menus ! * or while dragging. The default for {@code delay} is 0. * This method is a property of the look and feel code and is used * to manage the idiosyncrasies of the various UI implementations. * * ! * @return the {@code delay} property */ public int getDelay() { return delay; } /** ! * Sets the suggested delay before the menu's {@code PopupMenu} * is popped up or down. Each look and feel (L&amp;F) may determine * it's own policy for observing the delay property. In most cases, * the delay is not observed for top level menus or while dragging. * This method is a property of the look and feel code and is used * to manage the idiosyncrasies of the various UI implementations. * * @param d the number of milliseconds to delay ! * @exception IllegalArgumentException if {@code d} * is less than 0 * @beaninfo * description: The delay between menu selection and making the popup menu visible * expert: true */
*** 565,602 **** /** * Appends a menu item to the end of this menu. * Returns the menu item added. * ! * @param menuItem the <code>JMenuitem</code> to be added ! * @return the <code>JMenuItem</code> added */ public JMenuItem add(JMenuItem menuItem) { ensurePopupMenuCreated(); return popupMenu.add(menuItem); } /** * Appends a component to the end of this menu. * Returns the component added. * ! * @param c the <code>Component</code> to add ! * @return the <code>Component</code> added */ public Component add(Component c) { ensurePopupMenuCreated(); popupMenu.add(c); return c; } /** * Adds the specified component to this container at the given ! * position. If <code>index</code> equals -1, the component will * be appended to the end. ! * @param c the <code>Component</code> to add * @param index the position at which to insert the component ! * @return the <code>Component</code> added * @see #remove * @see java.awt.Container#add(Component, int) */ public Component add(Component c, int index) { ensurePopupMenuCreated(); --- 565,602 ---- /** * Appends a menu item to the end of this menu. * Returns the menu item added. * ! * @param menuItem the {@code JMenuitem} to be added ! * @return the {@code JMenuItem} added */ public JMenuItem add(JMenuItem menuItem) { ensurePopupMenuCreated(); return popupMenu.add(menuItem); } /** * Appends a component to the end of this menu. * Returns the component added. * ! * @param c the {@code Component} to add ! * @return the {@code Component} added */ public Component add(Component c) { ensurePopupMenuCreated(); popupMenu.add(c); return c; } /** * Adds the specified component to this container at the given ! * position. If {@code index} equals -1, the component will * be appended to the end. ! * @param c the {@code Component} to add * @param index the position at which to insert the component ! * @return the {@code Component} added * @see #remove * @see java.awt.Container#add(Component, int) */ public Component add(Component c, int index) { ensurePopupMenuCreated();
*** 629,642 **** add(mi); return mi; } /** ! * Factory method which creates the <code>JMenuItem</code> for ! * <code>Action</code>s added to the <code>JMenu</code>. * ! * @param a the <code>Action</code> for the menu item to be added * @return the new menu item * @see Action * * @since 1.3 */ --- 629,642 ---- add(mi); return mi; } /** ! * Factory method which creates the {@code JMenuItem} for ! * {@code Action}s added to the {@code JMenu}. * ! * @param a the {@code Action} for the menu item to be added * @return the new menu item * @see Action * * @since 1.3 */
*** 681,691 **** * * @param s the text for the menu item to add * @param pos an integer specifying the position at which to add the * new menu item * @exception IllegalArgumentException when the value of ! * <code>pos</code> &lt; 0 */ public void insert(String s, int pos) { if (pos < 0) { throw new IllegalArgumentException("index less than zero."); } --- 681,691 ---- * * @param s the text for the menu item to add * @param pos an integer specifying the position at which to add the * new menu item * @exception IllegalArgumentException when the value of ! * {@code pos < 0} */ public void insert(String s, int pos) { if (pos < 0) { throw new IllegalArgumentException("index less than zero."); }
*** 693,710 **** ensurePopupMenuCreated(); popupMenu.insert(new JMenuItem(s), pos); } /** ! * Inserts the specified <code>JMenuitem</code> at a given position. * ! * @param mi the <code>JMenuitem</code> to add * @param pos an integer specifying the position at which to add the ! * new <code>JMenuitem</code> * @return the new menu item * @exception IllegalArgumentException if the value of ! * <code>pos</code> &lt; 0 */ public JMenuItem insert(JMenuItem mi, int pos) { if (pos < 0) { throw new IllegalArgumentException("index less than zero."); } --- 693,710 ---- ensurePopupMenuCreated(); popupMenu.insert(new JMenuItem(s), pos); } /** ! * Inserts the specified {@code JMenuitem} at a given position. * ! * @param mi the {@code JMenuitem} to add * @param pos an integer specifying the position at which to add the ! * new {@code JMenuitem} * @return the new menu item * @exception IllegalArgumentException if the value of ! * {@code pos < 0} */ public JMenuItem insert(JMenuItem mi, int pos) { if (pos < 0) { throw new IllegalArgumentException("index less than zero."); }
*** 712,730 **** popupMenu.insert(mi, pos); return mi; } /** ! * Inserts a new menu item attached to the specified <code>Action</code> * object at a given position. * ! * @param a the <code>Action</code> object for the menu item to add * @param pos an integer specifying the position at which to add the * new menu item * @return the new menu item * @exception IllegalArgumentException if the value of ! * <code>pos</code> &lt; 0 */ public JMenuItem insert(Action a, int pos) { if (pos < 0) { throw new IllegalArgumentException("index less than zero."); } --- 712,730 ---- popupMenu.insert(mi, pos); return mi; } /** ! * Inserts a new menu item attached to the specified {@code Action} * object at a given position. * ! * @param a the {@code Action} object for the menu item to add * @param pos an integer specifying the position at which to add the * new menu item * @return the new menu item * @exception IllegalArgumentException if the value of ! * {@code pos < 0} */ public JMenuItem insert(Action a, int pos) { if (pos < 0) { throw new IllegalArgumentException("index less than zero."); }
*** 741,751 **** * Inserts a separator at the specified position. * * @param index an integer specifying the position at which to * insert the menu separator * @exception IllegalArgumentException if the value of ! * <code>index</code> &lt; 0 */ public void insertSeparator(int index) { if (index < 0) { throw new IllegalArgumentException("index less than zero."); } --- 741,751 ---- * Inserts a separator at the specified position. * * @param index an integer specifying the position at which to * insert the menu separator * @exception IllegalArgumentException if the value of ! * {@code index < 0} */ public void insertSeparator(int index) { if (index < 0) { throw new IllegalArgumentException("index less than zero."); }
*** 759,772 **** * If the component at {@code pos} is not a menu item, * {@code null} is returned. * This method is included for AWT compatibility. * * @param pos an integer specifying the position ! * @return the menu item at the specified position; or <code>null</code> * if the item as the specified position is not a menu item * @exception IllegalArgumentException if the value of ! * {@code pos} &lt; 0 */ public JMenuItem getItem(int pos) { if (pos < 0) { throw new IllegalArgumentException("index less than zero."); } --- 759,772 ---- * If the component at {@code pos} is not a menu item, * {@code null} is returned. * This method is included for AWT compatibility. * * @param pos an integer specifying the position ! * @return the menu item at the specified position; or {@code null} * if the item as the specified position is not a menu item * @exception IllegalArgumentException if the value of ! * {@code pos < 0} */ public JMenuItem getItem(int pos) { if (pos < 0) { throw new IllegalArgumentException("index less than zero."); }
*** 805,815 **** /** * Removes the specified menu item from this menu. If there is no * popup menu, this method will have no effect. * ! * @param item the <code>JMenuItem</code> to be removed from the menu */ public void remove(JMenuItem item) { if (popupMenu != null) popupMenu.remove(item); } --- 805,815 ---- /** * Removes the specified menu item from this menu. If there is no * popup menu, this method will have no effect. * ! * @param item the {@code JMenuItem} to be removed from the menu */ public void remove(JMenuItem item) { if (popupMenu != null) popupMenu.remove(item); }
*** 817,827 **** /** * Removes the menu item at the specified index from this menu. * * @param pos the position of the item to be removed * @exception IllegalArgumentException if the value of ! * <code>pos</code> &lt; 0, or if <code>pos</code> * is greater than the number of menu items */ public void remove(int pos) { if (pos < 0) { throw new IllegalArgumentException("index less than zero."); --- 817,827 ---- /** * Removes the menu item at the specified index from this menu. * * @param pos the position of the item to be removed * @exception IllegalArgumentException if the value of ! * {@code pos < 0}, or if {@code pos} * is greater than the number of menu items */ public void remove(int pos) { if (pos < 0) { throw new IllegalArgumentException("index less than zero.");
*** 832,842 **** if (popupMenu != null) popupMenu.remove(pos); } /** ! * Removes the component <code>c</code> from this menu. * * @param c the component to be removed */ public void remove(Component c) { if (popupMenu != null) --- 832,842 ---- if (popupMenu != null) popupMenu.remove(pos); } /** ! * Removes the component {@code c} from this menu. * * @param c the component to be removed */ public void remove(Component c) { if (popupMenu != null)
*** 862,875 **** componentCount = popupMenu.getComponentCount(); return componentCount; } /** ! * Returns the component at position <code>n</code>. * * @param n the position of the component to be returned ! * @return the component requested, or <code>null</code> * if there is no popup menu * */ public Component getMenuComponent(int n) { if (popupMenu != null) --- 862,875 ---- componentCount = popupMenu.getComponentCount(); return componentCount; } /** ! * Returns the component at position {@code n}. * * @param n the position of the component to be returned ! * @return the component requested, or {@code null} * if there is no popup menu * */ public Component getMenuComponent(int n) { if (popupMenu != null)
*** 877,891 **** return null; } /** ! * Returns an array of <code>Component</code>s of the menu's ! * subcomponents. Note that this returns all <code>Component</code>s * in the popup menu, including separators. * ! * @return an array of <code>Component</code>s or an empty array * if there is no popup menu */ public Component[] getMenuComponents() { if (popupMenu != null) return popupMenu.getComponents(); --- 877,891 ---- return null; } /** ! * Returns an array of {@code Component}s of the menu's ! * subcomponents. Note that this returns all {@code Component}s * in the popup menu, including separators. * ! * @return an array of {@code Component}s or an empty array * if there is no popup menu */ public Component[] getMenuComponents() { if (popupMenu != null) return popupMenu.getComponents();
*** 908,919 **** /** * Returns true if the specified component exists in the * submenu hierarchy. * ! * @param c the <code>Component</code> to be tested ! * @return true if the <code>Component</code> exists, false otherwise */ public boolean isMenuComponent(Component c) { // Are we in the MenuItem part of the menu if (c == this) return true; --- 908,919 ---- /** * Returns true if the specified component exists in the * submenu hierarchy. * ! * @param c the {@code Component} to be tested ! * @return true if the {@code Component} exists, false otherwise */ public boolean isMenuComponent(Component c) { // Are we in the MenuItem part of the menu if (c == this) return true;
*** 944,954 **** } /* * Returns a point in the coordinate space of this menu's popupmenu ! * which corresponds to the point <code>p</code> in the menu's * coordinate space. * * @param p the point to be translated * @return the point in the coordinate space of this menu's popupmenu */ --- 944,954 ---- } /* * Returns a point in the coordinate space of this menu's popupmenu ! * which corresponds to the point {@code p} in the menu's * coordinate space. * * @param p the point to be translated * @return the point in the coordinate space of this menu's popupmenu */
*** 1007,1020 **** public void removeMenuListener(MenuListener l) { listenerList.remove(MenuListener.class, l); } /** ! * Returns an array of all the <code>MenuListener</code>s added * to this JMenu with addMenuListener(). * ! * @return all of the <code>MenuListener</code>s added or an empty * array if no listeners have been added * @since 1.4 */ public MenuListener[] getMenuListeners() { return listenerList.getListeners(MenuListener.class); --- 1007,1020 ---- public void removeMenuListener(MenuListener l) { listenerList.remove(MenuListener.class, l); } /** ! * Returns an array of all the {@code MenuListener}s added * to this JMenu with addMenuListener(). * ! * @return all of the {@code MenuListener}s added or an empty * array if no listeners have been added * @since 1.4 */ public MenuListener[] getMenuListeners() { return listenerList.getListeners(MenuListener.class);
*** 1023,1033 **** /** * Notifies all listeners that have registered interest for * notification on this event type. The event instance * is created lazily. * ! * @exception Error if there is a <code>null</code> listener * @see EventListenerList */ protected void fireMenuSelected() { if (DEBUG) { System.out.println("In JMenu.fireMenuSelected"); --- 1023,1033 ---- /** * Notifies all listeners that have registered interest for * notification on this event type. The event instance * is created lazily. * ! * @exception Error if there is a {@code null} listener * @see EventListenerList */ protected void fireMenuSelected() { if (DEBUG) { System.out.println("In JMenu.fireMenuSelected");
*** 1053,1063 **** /** * Notifies all listeners that have registered interest for * notification on this event type. The event instance * is created lazily. * ! * @exception Error if there is a <code>null</code> listener * @see EventListenerList */ protected void fireMenuDeselected() { if (DEBUG) { System.out.println("In JMenu.fireMenuDeselected"); --- 1053,1063 ---- /** * Notifies all listeners that have registered interest for * notification on this event type. The event instance * is created lazily. * ! * @exception Error if there is a {@code null} listener * @see EventListenerList */ protected void fireMenuDeselected() { if (DEBUG) { System.out.println("In JMenu.fireMenuDeselected");
*** 1083,1093 **** /** * Notifies all listeners that have registered interest for * notification on this event type. The event instance * is created lazily. * ! * @exception Error if there is a <code>null</code> listener * @see EventListenerList */ protected void fireMenuCanceled() { if (DEBUG) { System.out.println("In JMenu.fireMenuCanceled"); --- 1083,1093 ---- /** * Notifies all listeners that have registered interest for * notification on this event type. The event instance * is created lazily. * ! * @exception Error if there is a {@code null} listener * @see EventListenerList */ protected void fireMenuCanceled() { if (DEBUG) { System.out.println("In JMenu.fireMenuCanceled");
*** 1139,1149 **** /** * Creates a window-closing listener for the popup. * ! * @param p the <code>JPopupMenu</code> * @return the new window-closing listener * * @see WinListener */ protected WinListener createWinListener(JPopupMenu p) { --- 1139,1149 ---- /** * Creates a window-closing listener for the popup. * ! * @param p the {@code JPopupMenu} * @return the new window-closing listener * * @see WinListener */ protected WinListener createWinListener(JPopupMenu p) {
*** 1158,1168 **** * 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&trade; ! * has been added to the <code>java.beans</code> package. * Please see {@link java.beans.XMLEncoder}. */ @SuppressWarnings("serial") protected class WinListener extends WindowAdapter implements Serializable { JPopupMenu popupMenu; --- 1158,1168 ---- * 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&trade; ! * has been added to the {@code java.beans} package. * Please see {@link java.beans.XMLEncoder}. */ @SuppressWarnings("serial") protected class WinListener extends WindowAdapter implements Serializable { JPopupMenu popupMenu;
*** 1184,1194 **** } /** * Messaged when the menubar selection changes to activate or * deactivate this menu. ! * Overrides <code>JMenuItem.menuSelectionChanged</code>. * * @param isIncluded true if this menu is active, false if * it is not */ public void menuSelectionChanged(boolean isIncluded) { --- 1184,1194 ---- } /** * Messaged when the menubar selection changes to activate or * deactivate this menu. ! * Overrides {@code JMenuItem.menuSelectionChanged}. * * @param isIncluded true if this menu is active, false if * it is not */ public void menuSelectionChanged(boolean isIncluded) {
*** 1197,1214 **** } setSelected(isIncluded); } /** ! * Returns an array of <code>MenuElement</code>s containing the submenu ! * for this menu component. If popup menu is <code>null</code> returns * an empty array. This method is required to conform to the ! * <code>MenuElement</code> interface. Note that since ! * <code>JSeparator</code>s do not conform to the <code>MenuElement</code> ! * interface, this array will only contain <code>JMenuItem</code>s. * ! * @return an array of <code>MenuElement</code> objects */ public MenuElement[] getSubElements() { if(popupMenu == null) return new MenuElement[0]; else { --- 1197,1214 ---- } setSelected(isIncluded); } /** ! * Returns an array of {@code MenuElement}s containing the submenu ! * for this menu component. If popup menu is {@code null} returns * an empty array. This method is required to conform to the ! * {@code MenuElement} interface. Note that since ! * {@code JSeparator}s do not conform to the {@code MenuElement} ! * interface, this array will only contain {@code JMenuItem}s. * ! * @return an array of {@code MenuElement} objects */ public MenuElement[] getSubElements() { if(popupMenu == null) return new MenuElement[0]; else {
*** 1219,1246 **** } // implements javax.swing.MenuElement /** ! * Returns the <code>java.awt.Component</code> used to ! * paint this <code>MenuElement</code>. * The returned component is used to convert events and detect if * an event is inside a menu component. */ public Component getComponent() { return this; } /** ! * Sets the <code>ComponentOrientation</code> property of this menu * and all components contained within it. This includes all * components returned by {@link #getMenuComponents getMenuComponents}. * * @param o the new component orientation of this menu and * the components contained within it. ! * @exception NullPointerException if <code>orientation</code> is null. * @see java.awt.Component#setComponentOrientation * @see java.awt.Component#getComponentOrientation * @since 1.4 */ public void applyComponentOrientation(ComponentOrientation o) { --- 1219,1246 ---- } // implements javax.swing.MenuElement /** ! * Returns the {@code java.awt.Component} used to ! * paint this {@code MenuElement}. * The returned component is used to convert events and detect if * an event is inside a menu component. */ public Component getComponent() { return this; } /** ! * Sets the {@code ComponentOrientation} property of this menu * and all components contained within it. This includes all * components returned by {@link #getMenuComponents getMenuComponents}. * * @param o the new component orientation of this menu and * the components contained within it. ! * @exception NullPointerException if {@code orientation} is null. * @see java.awt.Component#setComponentOrientation * @see java.awt.Component#getComponentOrientation * @since 1.4 */ public void applyComponentOrientation(ComponentOrientation o) {
*** 1261,1277 **** popupMenu.setComponentOrientation(o); } } /** ! * <code>setAccelerator</code> is not defined for <code>JMenu</code>. ! * Use <code>setMnemonic</code> instead. * @param keyStroke the keystroke combination which will invoke ! * the <code>JMenuItem</code>'s actionlisteners * without navigating the menu hierarchy * @exception Error if invoked -- this method is not defined for JMenu. ! * Use <code>setMnemonic</code> instead * * @beaninfo * description: The keystroke combination which will invoke the JMenuItem's * actionlisteners without navigating the menu hierarchy * hidden: true --- 1261,1277 ---- popupMenu.setComponentOrientation(o); } } /** ! * {@code setAccelerator} is not defined for {@code JMenu}. ! * Use {@code setMnemonic} instead. * @param keyStroke the keystroke combination which will invoke ! * the {@code JMenuItem}'s actionlisteners * without navigating the menu hierarchy * @exception Error if invoked -- this method is not defined for JMenu. ! * Use {@code setMnemonic} instead * * @beaninfo * description: The keystroke combination which will invoke the JMenuItem's * actionlisteners without navigating the menu hierarchy * hidden: true
*** 1293,1314 **** super.processKeyEvent(evt); } /** * Programmatically performs a "click". This overrides the method ! * <code>AbstractButton.doClick</code> in order to make the menu pop up. * @param pressTime indicates the number of milliseconds the * button was pressed for */ public void doClick(int pressTime) { MenuElement me[] = buildMenuElementArray(this); MenuSelectionManager.defaultManager().setSelectedPath(me); } /* ! * Build an array of menu elements - from <code>PopupMenu</code> to ! * the root <code>JMenuBar</code>. * @param leaf the leaf node from which to start building up the array * @return the array of menu items */ private MenuElement[] buildMenuElementArray(JMenu leaf) { Vector<MenuElement> elements = new Vector<MenuElement>(); --- 1293,1314 ---- super.processKeyEvent(evt); } /** * Programmatically performs a "click". This overrides the method ! * {@code AbstractButton.doClick} in order to make the menu pop up. * @param pressTime indicates the number of milliseconds the * button was pressed for */ public void doClick(int pressTime) { MenuElement me[] = buildMenuElementArray(this); MenuSelectionManager.defaultManager().setSelectedPath(me); } /* ! * Build an array of menu elements - from {@code PopupMenu} to ! * the root {@code JMenuBar}. * @param leaf the leaf node from which to start building up the array * @return the array of menu items */ private MenuElement[] buildMenuElementArray(JMenu leaf) { Vector<MenuElement> elements = new Vector<MenuElement>();
*** 1336,1347 **** } } /** ! * See <code>readObject</code> and <code>writeObject</code> in ! * <code>JComponent</code> for more * information about serialization in Swing. */ private void writeObject(ObjectOutputStream s) throws IOException { s.defaultWriteObject(); if (getUIClassID().equals(uiClassID)) { --- 1336,1347 ---- } } /** ! * See {@code readObject} and {@code writeObject} in ! * {@code JComponent} for more * information about serialization in Swing. */ private void writeObject(ObjectOutputStream s) throws IOException { s.defaultWriteObject(); if (getUIClassID().equals(uiClassID)) {
*** 1353,1367 **** } } /** ! * Returns a string representation of this <code>JMenu</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 JMenu. */ protected String paramString() { return super.paramString(); --- 1353,1367 ---- } } /** ! * Returns a string representation of this {@code JMenu}. 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 JMenu. */ protected String paramString() { return super.paramString();
*** 1388,1407 **** return accessibleContext; } /** * This class implements accessibility support for the ! * <code>JMenu</code> class. It provides an implementation of the * Java Accessibility API appropriate to menu user-interface elements. * <p> * <strong>Warning:</strong> * 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&trade; ! * has been added to the <code>java.beans</code> package. * Please see {@link java.beans.XMLEncoder}. */ @SuppressWarnings("serial") protected class AccessibleJMenu extends AccessibleJMenuItem implements AccessibleSelection { --- 1388,1407 ---- return accessibleContext; } /** * This class implements accessibility support for the ! * {@code JMenu} class. It provides an implementation of the * Java Accessibility API appropriate to menu user-interface elements. * <p> * <strong>Warning:</strong> * 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&trade; ! * has been added to the {@code java.beans} package. * Please see {@link java.beans.XMLEncoder}. */ @SuppressWarnings("serial") protected class AccessibleJMenu extends AccessibleJMenuItem implements AccessibleSelection {
*** 1548,1558 **** return false; } /** ! * Selects the <code>i</code>th menu in the menu. * If that item is a submenu, * it will pop up in response. If a different item is already * popped up, this will force it to close. If this is a sub-menu * that is already popped up (selected), this method has no * effect. --- 1548,1558 ---- return false; } /** ! * Selects the {@code i}th menu in the menu. * If that item is a submenu, * it will pop up in response. If a different item is already * popped up, this will force it to close. If this is a sub-menu * that is already popped up (selected), this method has no * effect.
< prev index next >