jdk/src/share/classes/javax/swing/JPopupMenu.java

Print this page

        

*** 20,53 **** * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ - package javax.swing; import java.awt.*; import java.awt.event.*; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; ! import java.beans.*; - import java.util.Locale; import java.util.Vector; - import java.util.Hashtable; import javax.accessibility.*; import javax.swing.plaf.PopupMenuUI; - import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicComboPopup; import javax.swing.event.*; import sun.awt.SunToolkit; - import sun.security.util.SecurityConstants; - - 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. --- 20,49 ---- * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package javax.swing; import java.awt.*; import java.awt.event.*; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; ! import java.beans.JavaBean; ! import java.beans.BeanProperty; ! import java.beans.PropertyChangeEvent; ! import java.beans.PropertyChangeListener; import java.util.Vector; import javax.accessibility.*; import javax.swing.plaf.PopupMenuUI; import javax.swing.plaf.basic.BasicComboPopup; import javax.swing.event.*; import sun.awt.SunToolkit; /** * 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.
*** 73,91 **** * 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 false - * description: A small window that pops up and displays a series of choices. - * * @author Georges Saab * @author David Karlton * @author Arnaud Weber * @since 1.2 */ @SuppressWarnings("serial") public class JPopupMenu extends JComponent implements Accessible,MenuElement { /** * @see #getUIClassID --- 69,85 ---- * 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}. * * @author Georges Saab * @author David Karlton * @author Arnaud Weber * @since 1.2 */ + @JavaBean(defaultProperty = "UI", description = "A small window that pops up and displays a series of choices.") + @SwingContainer(false) @SuppressWarnings("serial") public class JPopupMenu extends JComponent implements Accessible,MenuElement { /** * @see #getUIClassID
*** 208,223 **** /** * Sets the L&amp;F object that renders this component. * * @param ui the new <code>PopupMenuUI</code> L&amp;F object * @see UIDefaults#getUI - * @beaninfo - * bound: true - * hidden: true - * attribute: visualUpdate true - * description: The UI object that implements the Component's LookAndFeel. */ public void setUI(PopupMenuUI ui) { super.setUI(ui); } /** --- 202,214 ---- /** * Sets the L&amp;F object that renders this component. * * @param ui the new <code>PopupMenuUI</code> L&amp;F object * @see UIDefaults#getUI */ + @BeanProperty(hidden = true, visualUpdate = true, description + = "The UI object that implements the Component's LookAndFeel.") public void setUI(PopupMenuUI ui) { super.setUI(ui); } /**
*** 235,244 **** --- 226,236 ---- * * @return the string "PopupMenuUI" * @see JComponent#getUIClassID * @see UIDefaults#getUI */ + @BeanProperty(bound = false) public String getUIClassID() { return uiClassID; } protected void processFocusEvent(FocusEvent evt) {
*** 272,285 **** /** * 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 */ public void setSelectionModel(SingleSelectionModel model) { selectionModel = model; } /** --- 264,276 ---- /** * Sets the model object to handle single selections. * * @param model the new <code>SingleSelectionModel</code> * @see SingleSelectionModel */ + @BeanProperty(bound = false, expert = true, description + = "The selection model for the popup menu") public void setSelectionModel(SingleSelectionModel model) { selectionModel = model; } /**
*** 493,508 **** * 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 */ public void setLightWeightPopupEnabled(boolean aFlag) { // NOTE: this use to set the flag on a shared JPopupMenu, which meant // this effected ALL JPopupMenus. lightWeightPopup = aFlag; } --- 484,498 ---- * 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 * * @see #isLightWeightPopupEnabled */ + @BeanProperty(bound = false, expert = true, description + = "Determines whether lightweight popups are used when possible") public void setLightWeightPopupEnabled(boolean aFlag) { // NOTE: this use to set the flag on a shared JPopupMenu, which meant // this effected ALL JPopupMenus. lightWeightPopup = aFlag; }
*** 532,545 **** * to display or not display this. * * @param label a string specifying the label for the popup menu * * @see #setLabel - * @beaninfo - * description: The label for the popup menu. - * bound: true */ public void setLabel(String label) { String oldValue = this.label; this.label = label; firePropertyChange("label", oldValue, label); if (accessibleContext != null) { --- 522,534 ---- * to display or not display this. * * @param label a string specifying the label for the popup menu * * @see #setLabel */ + @BeanProperty(description + = "The label for the popup menu.") public void setLabel(String label) { String oldValue = this.label; this.label = label; firePropertyChange("label", oldValue, label); if (accessibleContext != null) {
*** 635,644 **** --- 624,634 ---- * * @return all of the <code>PopupMenuListener</code>s added or an empty * array if no listeners have been added * @since 1.4 */ + @BeanProperty(bound = false) public PopupMenuListener[] getPopupMenuListeners() { return listenerList.getListeners(PopupMenuListener.class); } /**
*** 667,676 **** --- 657,667 ---- * * @return all of the <code>MenuKeyListener</code>s added or an empty * array if no listeners have been added * @since 1.5 */ + @BeanProperty(bound = false) public MenuKeyListener[] getMenuKeyListeners() { return listenerList.getListeners(MenuKeyListener.class); } /**
*** 751,764 **** /** * Sets the visibility of the popup menu. * * @param b true to make the popup visible, or false to * hide it - * @beaninfo - * bound: true - * description: Makes the popup visible */ public void setVisible(boolean b) { if (DEBUG) { System.out.println("JPopupMenu.setVisible " + b); } --- 742,754 ---- /** * Sets the visibility of the popup menu. * * @param b true to make the popup visible, or false to * hide it */ + @BeanProperty(description + = "Makes the popup visible") public void setVisible(boolean b) { if (DEBUG) { System.out.println("JPopupMenu.setVisible " + b); }
*** 866,878 **** * * @param x the x coordinate of the popup's new position * in the screen's coordinate space * @param y the y coordinate of the popup's new position * in the screen's coordinate space - * @beaninfo - * description: The location of the popup menu. */ public void setLocation(int x, int y) { int oldX = desiredLocationX; int oldY = desiredLocationY; desiredLocationX = x; --- 856,868 ---- * * @param x the x coordinate of the popup's new position * in the screen's coordinate space * @param y the y coordinate of the popup's new position * in the screen's coordinate space */ + @BeanProperty(description + = "The location of the popup menu.") public void setLocation(int x, int y) { int oldX = desiredLocationX; int oldY = desiredLocationY; desiredLocationX = x;
*** 906,919 **** * 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 */ public void setInvoker(Component invoker) { Component oldInvoker = this.invoker; this.invoker = invoker; if ((oldInvoker != this.invoker) && (ui != null)) { ui.uninstallUI(this); --- 896,908 ---- * 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 */ + @BeanProperty(bound = false, expert = true, description + = "The invoking component for the popup menu") public void setInvoker(Component invoker) { Component oldInvoker = this.invoker; this.invoker = invoker; if ((oldInvoker != this.invoker) && (ui != null)) { ui.uninstallUI(this);
*** 1022,1034 **** * 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) { Dimension oldSize = getPreferredSize(); setPreferredSize(d); if (popup != null) { --- 1011,1023 ---- * 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. */ + @BeanProperty(description + = "The size of the popup menu") public void setPopupSize(Dimension d) { Dimension oldSize = getPreferredSize(); setPreferredSize(d); if (popup != null) {
*** 1045,1071 **** * 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 */ public void setPopupSize(int width, int height) { setPopupSize(new Dimension(width, height)); } /** * 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 */ public void setSelected(Component sel) { SingleSelectionModel model = getSelectionModel(); int index = getComponentIndex(sel); model.setSelectedIndex(index); } --- 1034,1058 ---- * 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 */ + @BeanProperty(description + = "The size of the popup menu") public void setPopupSize(int width, int height) { setPopupSize(new Dimension(width, height)); } /** * Sets the currently selected component, This will result * in a change to the selection model. * * @param sel the <code>Component</code> to select */ + @BeanProperty(expert = true, hidden = true, description + = "The selected component on the popup menu") public void setSelected(Component sel) { SingleSelectionModel model = getSelectionModel(); int index = getComponentIndex(sel); model.setSelectedIndex(index); }
*** 1083,1095 **** /** * Sets whether the border should be painted. * * @param b if true, the border is painted. * @see #isBorderPainted - * @beaninfo - * description: Is the border of the popup menu painted */ public void setBorderPainted(boolean b) { paintBorder = b; repaint(); } --- 1070,1082 ---- /** * Sets whether the border should be painted. * * @param b if true, the border is painted. * @see #isBorderPainted */ + @BeanProperty(bound = false, description + = "Is the border of the popup menu painted") public void setBorderPainted(boolean b) { paintBorder = b; repaint(); }
*** 1111,1120 **** --- 1098,1108 ---- * Returns the margin, in pixels, between the popup menu's border and * its containers. * * @return an <code>Insets</code> object containing the margin values. */ + @BeanProperty(bound = false) public Insets getMargin() { if(margin == null) { return new Insets(0,0,0,0); } else { return margin;
*** 1196,1205 **** --- 1184,1194 ---- * A new AccessibleJPopupMenu instance is created if necessary. * * @return an AccessibleJPopupMenu that serves as the * AccessibleContext of this JPopupMenu */ + @BeanProperty(bound = false) public AccessibleContext getAccessibleContext() { if (accessibleContext == null) { accessibleContext = new AccessibleJPopupMenu(); } return accessibleContext;
*** 1510,1519 **** --- 1499,1509 ---- * <code>MenuElement</code> interface. * * @return an array of <code>MenuElement</code> objects * @see MenuElement#getSubElements */ + @BeanProperty(bound = false) public MenuElement[] getSubElements() { MenuElement result[]; Vector<MenuElement> tmp = new Vector<MenuElement>(); int c = getComponentCount(); int i;