69 * configuring a menu. Refer to <a href="Action.html#buttonActions">
70 * Swing Components Supporting <code>Action</code></a> for more
71 * details, and you can find more information in <a
72 * href="https://docs.oracle.com/javase/tutorial/uiswing/misc/action.html">How
73 * to Use Actions</a>, a section in <em>The Java Tutorial</em>.
74 * <p>
75 * For information and examples of using menus see
76 * <a href="https://docs.oracle.com/javase/tutorial/uiswing/components/menu.html">How to Use Menus</a>,
77 * a section in <em>The Java Tutorial.</em>
78 * <p>
79 * <strong>Warning:</strong> Swing is not thread safe. For more
80 * information see <a
81 * href="package-summary.html#threading">Swing's Threading
82 * Policy</a>.
83 * <p>
84 * <strong>Warning:</strong>
85 * Serialized objects of this class will not be compatible with
86 * future Swing releases. The current serialization support is
87 * appropriate for short term storage or RMI between applications running
88 * the same version of Swing. As of 1.4, support for long term storage
89 * of all JavaBeans™
90 * has been added to the <code>java.beans</code> package.
91 * Please see {@link java.beans.XMLEncoder}.
92 *
93 * @author Georges Saab
94 * @author David Karlton
95 * @author Arnaud Weber
96 * @see JMenuItem
97 * @see JSeparator
98 * @see JMenuBar
99 * @see JPopupMenu
100 * @since 1.2
101 */
102 @JavaBean(description = "A popup window containing menu items displayed in a menu bar.")
103 @SwingContainer
104 @SuppressWarnings("serial")
105 public class JMenu extends JMenuItem implements Accessible,MenuElement
106 {
107 /**
108 * @see #getUIClassID
109 * @see #readObject
1131 * Creates a window-closing listener for the popup.
1132 *
1133 * @param p the <code>JPopupMenu</code>
1134 * @return the new window-closing listener
1135 *
1136 * @see WinListener
1137 */
1138 protected WinListener createWinListener(JPopupMenu p) {
1139 return new WinListener(p);
1140 }
1141
1142 /**
1143 * A listener class that watches for a popup window closing.
1144 * When the popup is closing, the listener deselects the menu.
1145 * <p>
1146 * <strong>Warning:</strong>
1147 * Serialized objects of this class will not be compatible with
1148 * future Swing releases. The current serialization support is
1149 * appropriate for short term storage or RMI between applications running
1150 * the same version of Swing. As of 1.4, support for long term storage
1151 * of all JavaBeans™
1152 * has been added to the <code>java.beans</code> package.
1153 * Please see {@link java.beans.XMLEncoder}.
1154 */
1155 @SuppressWarnings("serial")
1156 protected class WinListener extends WindowAdapter implements Serializable {
1157 JPopupMenu popupMenu;
1158 /**
1159 * Create the window listener for the specified popup.
1160 *
1161 * @param p the popup menu for which to create a listener
1162 * @since 1.4
1163 */
1164 public WinListener(JPopupMenu p) {
1165 this.popupMenu = p;
1166 }
1167 /**
1168 * Deselect the menu when the popup is closed from outside.
1169 */
1170 public void windowClosing(WindowEvent e) {
1171 setSelected(false);
1370 * AccessibleContext of this JMenu
1371 */
1372 @BeanProperty(bound = false)
1373 public AccessibleContext getAccessibleContext() {
1374 if (accessibleContext == null) {
1375 accessibleContext = new AccessibleJMenu();
1376 }
1377 return accessibleContext;
1378 }
1379
1380 /**
1381 * This class implements accessibility support for the
1382 * <code>JMenu</code> class. It provides an implementation of the
1383 * Java Accessibility API appropriate to menu user-interface elements.
1384 * <p>
1385 * <strong>Warning:</strong>
1386 * Serialized objects of this class will not be compatible with
1387 * future Swing releases. The current serialization support is
1388 * appropriate for short term storage or RMI between applications running
1389 * the same version of Swing. As of 1.4, support for long term storage
1390 * of all JavaBeans™
1391 * has been added to the <code>java.beans</code> package.
1392 * Please see {@link java.beans.XMLEncoder}.
1393 */
1394 @SuppressWarnings("serial")
1395 protected class AccessibleJMenu extends AccessibleJMenuItem
1396 implements AccessibleSelection {
1397
1398 /**
1399 * Returns the number of accessible children in the object. If all
1400 * of the children of this object implement Accessible, than this
1401 * method should return the number of children of this object.
1402 *
1403 * @return the number of accessible children in the object.
1404 */
1405 public int getAccessibleChildrenCount() {
1406 Component[] children = getMenuComponents();
1407 int count = 0;
1408 for (Component child : children) {
1409 if (child instanceof Accessible) {
1410 count++;
|
69 * configuring a menu. Refer to <a href="Action.html#buttonActions">
70 * Swing Components Supporting <code>Action</code></a> for more
71 * details, and you can find more information in <a
72 * href="https://docs.oracle.com/javase/tutorial/uiswing/misc/action.html">How
73 * to Use Actions</a>, a section in <em>The Java Tutorial</em>.
74 * <p>
75 * For information and examples of using menus see
76 * <a href="https://docs.oracle.com/javase/tutorial/uiswing/components/menu.html">How to Use Menus</a>,
77 * a section in <em>The Java Tutorial.</em>
78 * <p>
79 * <strong>Warning:</strong> Swing is not thread safe. For more
80 * information see <a
81 * href="package-summary.html#threading">Swing's Threading
82 * Policy</a>.
83 * <p>
84 * <strong>Warning:</strong>
85 * Serialized objects of this class will not be compatible with
86 * future Swing releases. The current serialization support is
87 * appropriate for short term storage or RMI between applications running
88 * the same version of Swing. As of 1.4, support for long term storage
89 * of all JavaBeans
90 * has been added to the <code>java.beans</code> package.
91 * Please see {@link java.beans.XMLEncoder}.
92 *
93 * @author Georges Saab
94 * @author David Karlton
95 * @author Arnaud Weber
96 * @see JMenuItem
97 * @see JSeparator
98 * @see JMenuBar
99 * @see JPopupMenu
100 * @since 1.2
101 */
102 @JavaBean(description = "A popup window containing menu items displayed in a menu bar.")
103 @SwingContainer
104 @SuppressWarnings("serial")
105 public class JMenu extends JMenuItem implements Accessible,MenuElement
106 {
107 /**
108 * @see #getUIClassID
109 * @see #readObject
1131 * Creates a window-closing listener for the popup.
1132 *
1133 * @param p the <code>JPopupMenu</code>
1134 * @return the new window-closing listener
1135 *
1136 * @see WinListener
1137 */
1138 protected WinListener createWinListener(JPopupMenu p) {
1139 return new WinListener(p);
1140 }
1141
1142 /**
1143 * A listener class that watches for a popup window closing.
1144 * When the popup is closing, the listener deselects the menu.
1145 * <p>
1146 * <strong>Warning:</strong>
1147 * Serialized objects of this class will not be compatible with
1148 * future Swing releases. The current serialization support is
1149 * appropriate for short term storage or RMI between applications running
1150 * the same version of Swing. As of 1.4, support for long term storage
1151 * of all JavaBeans
1152 * has been added to the <code>java.beans</code> package.
1153 * Please see {@link java.beans.XMLEncoder}.
1154 */
1155 @SuppressWarnings("serial")
1156 protected class WinListener extends WindowAdapter implements Serializable {
1157 JPopupMenu popupMenu;
1158 /**
1159 * Create the window listener for the specified popup.
1160 *
1161 * @param p the popup menu for which to create a listener
1162 * @since 1.4
1163 */
1164 public WinListener(JPopupMenu p) {
1165 this.popupMenu = p;
1166 }
1167 /**
1168 * Deselect the menu when the popup is closed from outside.
1169 */
1170 public void windowClosing(WindowEvent e) {
1171 setSelected(false);
1370 * AccessibleContext of this JMenu
1371 */
1372 @BeanProperty(bound = false)
1373 public AccessibleContext getAccessibleContext() {
1374 if (accessibleContext == null) {
1375 accessibleContext = new AccessibleJMenu();
1376 }
1377 return accessibleContext;
1378 }
1379
1380 /**
1381 * This class implements accessibility support for the
1382 * <code>JMenu</code> class. It provides an implementation of the
1383 * Java Accessibility API appropriate to menu user-interface elements.
1384 * <p>
1385 * <strong>Warning:</strong>
1386 * Serialized objects of this class will not be compatible with
1387 * future Swing releases. The current serialization support is
1388 * appropriate for short term storage or RMI between applications running
1389 * the same version of Swing. As of 1.4, support for long term storage
1390 * of all JavaBeans
1391 * has been added to the <code>java.beans</code> package.
1392 * Please see {@link java.beans.XMLEncoder}.
1393 */
1394 @SuppressWarnings("serial")
1395 protected class AccessibleJMenu extends AccessibleJMenuItem
1396 implements AccessibleSelection {
1397
1398 /**
1399 * Returns the number of accessible children in the object. If all
1400 * of the children of this object implement Accessible, than this
1401 * method should return the number of children of this object.
1402 *
1403 * @return the number of accessible children in the object.
1404 */
1405 public int getAccessibleChildrenCount() {
1406 Component[] children = getMenuComponents();
1407 int count = 0;
1408 for (Component child : children) {
1409 if (child instanceof Accessible) {
1410 count++;
|