159 * @see #getShortcut()
160 * @see #setShortcut(MenuShortcut)
161 * @see #deleteShortcut()
162 */
163 private MenuShortcut shortcut = null;
164
165 private static final String base = "menuitem";
166 private static int nameCounter = 0;
167
168 /*
169 * JDK 1.1 serialVersionUID
170 */
171 private static final long serialVersionUID = -21757335363267194L;
172
173 /**
174 * Constructs a new MenuItem with an empty label and no keyboard
175 * shortcut.
176 * @exception HeadlessException if GraphicsEnvironment.isHeadless()
177 * returns true.
178 * @see java.awt.GraphicsEnvironment#isHeadless
179 * @since JDK1.1
180 */
181 public MenuItem() throws HeadlessException {
182 this("", null);
183 }
184
185 /**
186 * Constructs a new MenuItem with the specified label
187 * and no keyboard shortcut. Note that use of "-" in
188 * a label is reserved to indicate a separator between
189 * menu items. By default, all menu items except for
190 * separators are enabled.
191 * @param label the label for this menu item.
192 * @exception HeadlessException if GraphicsEnvironment.isHeadless()
193 * returns true.
194 * @see java.awt.GraphicsEnvironment#isHeadless
195 * @since JDK1.0
196 */
197 public MenuItem(String label) throws HeadlessException {
198 this(label, null);
199 }
200
201 /**
202 * Create a menu item with an associated keyboard shortcut.
203 * Note that use of "-" in a label is reserved to indicate
204 * a separator between menu items. By default, all menu
205 * items except for separators are enabled.
206 * @param label the label for this menu item.
207 * @param s the instance of <code>MenuShortcut</code>
208 * associated with this menu item.
209 * @exception HeadlessException if GraphicsEnvironment.isHeadless()
210 * returns true.
211 * @see java.awt.GraphicsEnvironment#isHeadless
212 * @since JDK1.1
213 */
214 public MenuItem(String label, MenuShortcut s) throws HeadlessException {
215 this.label = label;
216 this.shortcut = s;
217 }
218
219 /**
220 * Construct a name for this MenuComponent. Called by getName() when
221 * the name is null.
222 */
223 String constructComponentName() {
224 synchronized (MenuItem.class) {
225 return base + nameCounter++;
226 }
227 }
228
229 /**
230 * Creates the menu item's peer. The peer allows us to modify the
231 * appearance of the menu item without changing its functionality.
232 */
233 public void addNotify() {
234 synchronized (getTreeLock()) {
235 if (peer == null)
236 peer = Toolkit.getDefaultToolkit().createMenuItem(this);
237 }
238 }
239
240 /**
241 * Gets the label for this menu item.
242 * @return the label of this menu item, or <code>null</code>
243 if this menu item has no label.
244 * @see java.awt.MenuItem#setLabel
245 * @since JDK1.0
246 */
247 public String getLabel() {
248 return label;
249 }
250
251 /**
252 * Sets the label for this menu item to the specified label.
253 * @param label the new label, or <code>null</code> for no label.
254 * @see java.awt.MenuItem#getLabel
255 * @since JDK1.0
256 */
257 public synchronized void setLabel(String label) {
258 this.label = label;
259 MenuItemPeer peer = (MenuItemPeer)this.peer;
260 if (peer != null) {
261 peer.setLabel(label);
262 }
263 }
264
265 /**
266 * Checks whether this menu item is enabled.
267 * @see java.awt.MenuItem#setEnabled
268 * @since JDK1.0
269 */
270 public boolean isEnabled() {
271 return enabled;
272 }
273
274 /**
275 * Sets whether or not this menu item can be chosen.
276 * @param b if <code>true</code>, enables this menu item;
277 * if <code>false</code>, disables it.
278 * @see java.awt.MenuItem#isEnabled
279 * @since JDK1.1
280 */
281 public synchronized void setEnabled(boolean b) {
282 enable(b);
283 }
284
285 /**
286 * @deprecated As of JDK version 1.1,
287 * replaced by <code>setEnabled(boolean)</code>.
288 */
289 @Deprecated
290 public synchronized void enable() {
291 enabled = true;
292 MenuItemPeer peer = (MenuItemPeer)this.peer;
293 if (peer != null) {
294 peer.setEnabled(true);
295 }
296 }
297
298 /**
299 * @deprecated As of JDK version 1.1,
310
311 /**
312 * @deprecated As of JDK version 1.1,
313 * replaced by <code>setEnabled(boolean)</code>.
314 */
315 @Deprecated
316 public synchronized void disable() {
317 enabled = false;
318 MenuItemPeer peer = (MenuItemPeer)this.peer;
319 if (peer != null) {
320 peer.setEnabled(false);
321 }
322 }
323
324 /**
325 * Get the <code>MenuShortcut</code> object associated with this
326 * menu item,
327 * @return the menu shortcut associated with this menu item,
328 * or <code>null</code> if none has been specified.
329 * @see java.awt.MenuItem#setShortcut
330 * @since JDK1.1
331 */
332 public MenuShortcut getShortcut() {
333 return shortcut;
334 }
335
336 /**
337 * Set the <code>MenuShortcut</code> object associated with this
338 * menu item. If a menu shortcut is already associated with
339 * this menu item, it is replaced.
340 * @param s the menu shortcut to associate
341 * with this menu item.
342 * @see java.awt.MenuItem#getShortcut
343 * @since JDK1.1
344 */
345 public void setShortcut(MenuShortcut s) {
346 shortcut = s;
347 MenuItemPeer peer = (MenuItemPeer)this.peer;
348 if (peer != null) {
349 peer.setLabel(label);
350 }
351 }
352
353 /**
354 * Delete any <code>MenuShortcut</code> object associated
355 * with this menu item.
356 * @since JDK1.1
357 */
358 public void deleteShortcut() {
359 shortcut = null;
360 MenuItemPeer peer = (MenuItemPeer)this.peer;
361 if (peer != null) {
362 peer.setLabel(label);
363 }
364 }
365
366 /*
367 * Delete a matching MenuShortcut associated with this MenuItem.
368 * Used when iterating Menus.
369 */
370 void deleteShortcut(MenuShortcut s) {
371 if (s.equals(shortcut)) {
372 shortcut = null;
373 MenuItemPeer peer = (MenuItemPeer)this.peer;
374 if (peer != null) {
375 peer.setLabel(label);
376 }
438 }
439
440 MenuItem getShortcutMenuItem(MenuShortcut s) {
441 return (s.equals(shortcut)) ? this : null;
442 }
443
444 /**
445 * Enables event delivery to this menu item for events
446 * to be defined by the specified event mask parameter
447 * <p>
448 * Since event types are automatically enabled when a listener for
449 * that type is added to the menu item, this method only needs
450 * to be invoked by subclasses of <code>MenuItem</code> which desire to
451 * have the specified event types delivered to <code>processEvent</code>
452 * regardless of whether a listener is registered.
453 *
454 * @param eventsToEnable the event mask defining the event types
455 * @see java.awt.MenuItem#processEvent
456 * @see java.awt.MenuItem#disableEvents
457 * @see java.awt.Component#enableEvents
458 * @since JDK1.1
459 */
460 protected final void enableEvents(long eventsToEnable) {
461 eventMask |= eventsToEnable;
462 newEventsOnly = true;
463 }
464
465 /**
466 * Disables event delivery to this menu item for events
467 * defined by the specified event mask parameter.
468 *
469 * @param eventsToDisable the event mask defining the event types
470 * @see java.awt.MenuItem#processEvent
471 * @see java.awt.MenuItem#enableEvents
472 * @see java.awt.Component#disableEvents
473 * @since JDK1.1
474 */
475 protected final void disableEvents(long eventsToDisable) {
476 eventMask &= ~eventsToDisable;
477 }
478
479 /**
480 * Sets the command name of the action event that is fired
481 * by this menu item.
482 * <p>
483 * By default, the action command is set to the label of
484 * the menu item.
485 * @param command the action command to be set
486 * for this menu item.
487 * @see java.awt.MenuItem#getActionCommand
488 * @since JDK1.1
489 */
490 public void setActionCommand(String command) {
491 actionCommand = command;
492 }
493
494 /**
495 * Gets the command name of the action event that is fired
496 * by this menu item.
497 * @see java.awt.MenuItem#setActionCommand
498 * @since JDK1.1
499 */
500 public String getActionCommand() {
501 return getActionCommandImpl();
502 }
503
504 // This is final so it can be called on the Toolkit thread.
505 final String getActionCommandImpl() {
506 return (actionCommand == null? label : actionCommand);
507 }
508
509 /**
510 * Adds the specified action listener to receive action events
511 * from this menu item.
512 * If l is null, no exception is thrown and no action is performed.
513 * <p>Refer to <a href="doc-files/AWTThreadIssues.html#ListenersThreads"
514 * >AWT Threading Issues</a> for details on AWT's threading model.
515 *
516 * @param l the action listener.
517 * @see #removeActionListener
518 * @see #getActionListeners
519 * @see java.awt.event.ActionEvent
520 * @see java.awt.event.ActionListener
521 * @since JDK1.1
522 */
523 public synchronized void addActionListener(ActionListener l) {
524 if (l == null) {
525 return;
526 }
527 actionListener = AWTEventMulticaster.add(actionListener, l);
528 newEventsOnly = true;
529 }
530
531 /**
532 * Removes the specified action listener so it no longer receives
533 * action events from this menu item.
534 * If l is null, no exception is thrown and no action is performed.
535 * <p>Refer to <a href="doc-files/AWTThreadIssues.html#ListenersThreads"
536 * >AWT Threading Issues</a> for details on AWT's threading model.
537 *
538 * @param l the action listener.
539 * @see #addActionListener
540 * @see #getActionListeners
541 * @see java.awt.event.ActionEvent
542 * @see java.awt.event.ActionListener
543 * @since JDK1.1
544 */
545 public synchronized void removeActionListener(ActionListener l) {
546 if (l == null) {
547 return;
548 }
549 actionListener = AWTEventMulticaster.remove(actionListener, l);
550 }
551
552 /**
553 * Returns an array of all the action listeners
554 * registered on this menu item.
555 *
556 * @return all of this menu item's <code>ActionListener</code>s
557 * or an empty array if no action
558 * listeners are currently registered
559 *
560 * @see #addActionListener
561 * @see #removeActionListener
562 * @see java.awt.event.ActionEvent
563 * @see java.awt.event.ActionListener
604 EventListener l = null;
605 if (listenerType == ActionListener.class) {
606 l = actionListener;
607 }
608 return AWTEventMulticaster.getListeners(l, listenerType);
609 }
610
611 /**
612 * Processes events on this menu item. If the event is an
613 * instance of <code>ActionEvent</code>, it invokes
614 * <code>processActionEvent</code>, another method
615 * defined by <code>MenuItem</code>.
616 * <p>
617 * Currently, menu items only support action events.
618 * <p>Note that if the event parameter is <code>null</code>
619 * the behavior is unspecified and may result in an
620 * exception.
621 *
622 * @param e the event
623 * @see java.awt.MenuItem#processActionEvent
624 * @since JDK1.1
625 */
626 protected void processEvent(AWTEvent e) {
627 if (e instanceof ActionEvent) {
628 processActionEvent((ActionEvent)e);
629 }
630 }
631
632 // REMIND: remove when filtering is done at lower level
633 boolean eventEnabled(AWTEvent e) {
634 if (e.id == ActionEvent.ACTION_PERFORMED) {
635 if ((eventMask & AWTEvent.ACTION_EVENT_MASK) != 0 ||
636 actionListener != null) {
637 return true;
638 }
639 return false;
640 }
641 return super.eventEnabled(e);
642 }
643
644 /**
645 * Processes action events occurring on this menu item,
646 * by dispatching them to any registered
647 * <code>ActionListener</code> objects.
648 * This method is not called unless action events are
649 * enabled for this component. Action events are enabled
650 * when one of the following occurs:
651 * <ul>
652 * <li>An <code>ActionListener</code> object is registered
653 * via <code>addActionListener</code>.
654 * <li>Action events are enabled via <code>enableEvents</code>.
655 * </ul>
656 * <p>Note that if the event parameter is <code>null</code>
657 * the behavior is unspecified and may result in an
658 * exception.
659 *
660 * @param e the action event
661 * @see java.awt.event.ActionEvent
662 * @see java.awt.event.ActionListener
663 * @see java.awt.MenuItem#enableEvents
664 * @since JDK1.1
665 */
666 protected void processActionEvent(ActionEvent e) {
667 ActionListener listener = actionListener;
668 if (listener != null) {
669 listener.actionPerformed(e);
670 }
671 }
672
673 /**
674 * Returns a string representing the state of this <code>MenuItem</code>.
675 * This method is intended to be used only for debugging purposes, and the
676 * content and format of the returned string may vary between
677 * implementations. The returned string may be empty but may not be
678 * <code>null</code>.
679 *
680 * @return the parameter string of this menu item
681 */
682 public String paramString() {
683 String str = ",label=" + label;
684 if (shortcut != null) {
|
159 * @see #getShortcut()
160 * @see #setShortcut(MenuShortcut)
161 * @see #deleteShortcut()
162 */
163 private MenuShortcut shortcut = null;
164
165 private static final String base = "menuitem";
166 private static int nameCounter = 0;
167
168 /*
169 * JDK 1.1 serialVersionUID
170 */
171 private static final long serialVersionUID = -21757335363267194L;
172
173 /**
174 * Constructs a new MenuItem with an empty label and no keyboard
175 * shortcut.
176 * @exception HeadlessException if GraphicsEnvironment.isHeadless()
177 * returns true.
178 * @see java.awt.GraphicsEnvironment#isHeadless
179 * @since 1.1
180 */
181 public MenuItem() throws HeadlessException {
182 this("", null);
183 }
184
185 /**
186 * Constructs a new MenuItem with the specified label
187 * and no keyboard shortcut. Note that use of "-" in
188 * a label is reserved to indicate a separator between
189 * menu items. By default, all menu items except for
190 * separators are enabled.
191 * @param label the label for this menu item.
192 * @exception HeadlessException if GraphicsEnvironment.isHeadless()
193 * returns true.
194 * @see java.awt.GraphicsEnvironment#isHeadless
195 * @since 1.0
196 */
197 public MenuItem(String label) throws HeadlessException {
198 this(label, null);
199 }
200
201 /**
202 * Create a menu item with an associated keyboard shortcut.
203 * Note that use of "-" in a label is reserved to indicate
204 * a separator between menu items. By default, all menu
205 * items except for separators are enabled.
206 * @param label the label for this menu item.
207 * @param s the instance of <code>MenuShortcut</code>
208 * associated with this menu item.
209 * @exception HeadlessException if GraphicsEnvironment.isHeadless()
210 * returns true.
211 * @see java.awt.GraphicsEnvironment#isHeadless
212 * @since 1.1
213 */
214 public MenuItem(String label, MenuShortcut s) throws HeadlessException {
215 this.label = label;
216 this.shortcut = s;
217 }
218
219 /**
220 * Construct a name for this MenuComponent. Called by getName() when
221 * the name is null.
222 */
223 String constructComponentName() {
224 synchronized (MenuItem.class) {
225 return base + nameCounter++;
226 }
227 }
228
229 /**
230 * Creates the menu item's peer. The peer allows us to modify the
231 * appearance of the menu item without changing its functionality.
232 */
233 public void addNotify() {
234 synchronized (getTreeLock()) {
235 if (peer == null)
236 peer = Toolkit.getDefaultToolkit().createMenuItem(this);
237 }
238 }
239
240 /**
241 * Gets the label for this menu item.
242 * @return the label of this menu item, or <code>null</code>
243 if this menu item has no label.
244 * @see java.awt.MenuItem#setLabel
245 * @since 1.0
246 */
247 public String getLabel() {
248 return label;
249 }
250
251 /**
252 * Sets the label for this menu item to the specified label.
253 * @param label the new label, or <code>null</code> for no label.
254 * @see java.awt.MenuItem#getLabel
255 * @since 1.0
256 */
257 public synchronized void setLabel(String label) {
258 this.label = label;
259 MenuItemPeer peer = (MenuItemPeer)this.peer;
260 if (peer != null) {
261 peer.setLabel(label);
262 }
263 }
264
265 /**
266 * Checks whether this menu item is enabled.
267 * @see java.awt.MenuItem#setEnabled
268 * @since 1.0
269 */
270 public boolean isEnabled() {
271 return enabled;
272 }
273
274 /**
275 * Sets whether or not this menu item can be chosen.
276 * @param b if <code>true</code>, enables this menu item;
277 * if <code>false</code>, disables it.
278 * @see java.awt.MenuItem#isEnabled
279 * @since 1.1
280 */
281 public synchronized void setEnabled(boolean b) {
282 enable(b);
283 }
284
285 /**
286 * @deprecated As of JDK version 1.1,
287 * replaced by <code>setEnabled(boolean)</code>.
288 */
289 @Deprecated
290 public synchronized void enable() {
291 enabled = true;
292 MenuItemPeer peer = (MenuItemPeer)this.peer;
293 if (peer != null) {
294 peer.setEnabled(true);
295 }
296 }
297
298 /**
299 * @deprecated As of JDK version 1.1,
310
311 /**
312 * @deprecated As of JDK version 1.1,
313 * replaced by <code>setEnabled(boolean)</code>.
314 */
315 @Deprecated
316 public synchronized void disable() {
317 enabled = false;
318 MenuItemPeer peer = (MenuItemPeer)this.peer;
319 if (peer != null) {
320 peer.setEnabled(false);
321 }
322 }
323
324 /**
325 * Get the <code>MenuShortcut</code> object associated with this
326 * menu item,
327 * @return the menu shortcut associated with this menu item,
328 * or <code>null</code> if none has been specified.
329 * @see java.awt.MenuItem#setShortcut
330 * @since 1.1
331 */
332 public MenuShortcut getShortcut() {
333 return shortcut;
334 }
335
336 /**
337 * Set the <code>MenuShortcut</code> object associated with this
338 * menu item. If a menu shortcut is already associated with
339 * this menu item, it is replaced.
340 * @param s the menu shortcut to associate
341 * with this menu item.
342 * @see java.awt.MenuItem#getShortcut
343 * @since 1.1
344 */
345 public void setShortcut(MenuShortcut s) {
346 shortcut = s;
347 MenuItemPeer peer = (MenuItemPeer)this.peer;
348 if (peer != null) {
349 peer.setLabel(label);
350 }
351 }
352
353 /**
354 * Delete any <code>MenuShortcut</code> object associated
355 * with this menu item.
356 * @since 1.1
357 */
358 public void deleteShortcut() {
359 shortcut = null;
360 MenuItemPeer peer = (MenuItemPeer)this.peer;
361 if (peer != null) {
362 peer.setLabel(label);
363 }
364 }
365
366 /*
367 * Delete a matching MenuShortcut associated with this MenuItem.
368 * Used when iterating Menus.
369 */
370 void deleteShortcut(MenuShortcut s) {
371 if (s.equals(shortcut)) {
372 shortcut = null;
373 MenuItemPeer peer = (MenuItemPeer)this.peer;
374 if (peer != null) {
375 peer.setLabel(label);
376 }
438 }
439
440 MenuItem getShortcutMenuItem(MenuShortcut s) {
441 return (s.equals(shortcut)) ? this : null;
442 }
443
444 /**
445 * Enables event delivery to this menu item for events
446 * to be defined by the specified event mask parameter
447 * <p>
448 * Since event types are automatically enabled when a listener for
449 * that type is added to the menu item, this method only needs
450 * to be invoked by subclasses of <code>MenuItem</code> which desire to
451 * have the specified event types delivered to <code>processEvent</code>
452 * regardless of whether a listener is registered.
453 *
454 * @param eventsToEnable the event mask defining the event types
455 * @see java.awt.MenuItem#processEvent
456 * @see java.awt.MenuItem#disableEvents
457 * @see java.awt.Component#enableEvents
458 * @since 1.1
459 */
460 protected final void enableEvents(long eventsToEnable) {
461 eventMask |= eventsToEnable;
462 newEventsOnly = true;
463 }
464
465 /**
466 * Disables event delivery to this menu item for events
467 * defined by the specified event mask parameter.
468 *
469 * @param eventsToDisable the event mask defining the event types
470 * @see java.awt.MenuItem#processEvent
471 * @see java.awt.MenuItem#enableEvents
472 * @see java.awt.Component#disableEvents
473 * @since 1.1
474 */
475 protected final void disableEvents(long eventsToDisable) {
476 eventMask &= ~eventsToDisable;
477 }
478
479 /**
480 * Sets the command name of the action event that is fired
481 * by this menu item.
482 * <p>
483 * By default, the action command is set to the label of
484 * the menu item.
485 * @param command the action command to be set
486 * for this menu item.
487 * @see java.awt.MenuItem#getActionCommand
488 * @since 1.1
489 */
490 public void setActionCommand(String command) {
491 actionCommand = command;
492 }
493
494 /**
495 * Gets the command name of the action event that is fired
496 * by this menu item.
497 * @see java.awt.MenuItem#setActionCommand
498 * @since 1.1
499 */
500 public String getActionCommand() {
501 return getActionCommandImpl();
502 }
503
504 // This is final so it can be called on the Toolkit thread.
505 final String getActionCommandImpl() {
506 return (actionCommand == null? label : actionCommand);
507 }
508
509 /**
510 * Adds the specified action listener to receive action events
511 * from this menu item.
512 * If l is null, no exception is thrown and no action is performed.
513 * <p>Refer to <a href="doc-files/AWTThreadIssues.html#ListenersThreads"
514 * >AWT Threading Issues</a> for details on AWT's threading model.
515 *
516 * @param l the action listener.
517 * @see #removeActionListener
518 * @see #getActionListeners
519 * @see java.awt.event.ActionEvent
520 * @see java.awt.event.ActionListener
521 * @since 1.1
522 */
523 public synchronized void addActionListener(ActionListener l) {
524 if (l == null) {
525 return;
526 }
527 actionListener = AWTEventMulticaster.add(actionListener, l);
528 newEventsOnly = true;
529 }
530
531 /**
532 * Removes the specified action listener so it no longer receives
533 * action events from this menu item.
534 * If l is null, no exception is thrown and no action is performed.
535 * <p>Refer to <a href="doc-files/AWTThreadIssues.html#ListenersThreads"
536 * >AWT Threading Issues</a> for details on AWT's threading model.
537 *
538 * @param l the action listener.
539 * @see #addActionListener
540 * @see #getActionListeners
541 * @see java.awt.event.ActionEvent
542 * @see java.awt.event.ActionListener
543 * @since 1.1
544 */
545 public synchronized void removeActionListener(ActionListener l) {
546 if (l == null) {
547 return;
548 }
549 actionListener = AWTEventMulticaster.remove(actionListener, l);
550 }
551
552 /**
553 * Returns an array of all the action listeners
554 * registered on this menu item.
555 *
556 * @return all of this menu item's <code>ActionListener</code>s
557 * or an empty array if no action
558 * listeners are currently registered
559 *
560 * @see #addActionListener
561 * @see #removeActionListener
562 * @see java.awt.event.ActionEvent
563 * @see java.awt.event.ActionListener
604 EventListener l = null;
605 if (listenerType == ActionListener.class) {
606 l = actionListener;
607 }
608 return AWTEventMulticaster.getListeners(l, listenerType);
609 }
610
611 /**
612 * Processes events on this menu item. If the event is an
613 * instance of <code>ActionEvent</code>, it invokes
614 * <code>processActionEvent</code>, another method
615 * defined by <code>MenuItem</code>.
616 * <p>
617 * Currently, menu items only support action events.
618 * <p>Note that if the event parameter is <code>null</code>
619 * the behavior is unspecified and may result in an
620 * exception.
621 *
622 * @param e the event
623 * @see java.awt.MenuItem#processActionEvent
624 * @since 1.1
625 */
626 protected void processEvent(AWTEvent e) {
627 if (e instanceof ActionEvent) {
628 processActionEvent((ActionEvent)e);
629 }
630 }
631
632 // REMIND: remove when filtering is done at lower level
633 boolean eventEnabled(AWTEvent e) {
634 if (e.id == ActionEvent.ACTION_PERFORMED) {
635 if ((eventMask & AWTEvent.ACTION_EVENT_MASK) != 0 ||
636 actionListener != null) {
637 return true;
638 }
639 return false;
640 }
641 return super.eventEnabled(e);
642 }
643
644 /**
645 * Processes action events occurring on this menu item,
646 * by dispatching them to any registered
647 * <code>ActionListener</code> objects.
648 * This method is not called unless action events are
649 * enabled for this component. Action events are enabled
650 * when one of the following occurs:
651 * <ul>
652 * <li>An <code>ActionListener</code> object is registered
653 * via <code>addActionListener</code>.
654 * <li>Action events are enabled via <code>enableEvents</code>.
655 * </ul>
656 * <p>Note that if the event parameter is <code>null</code>
657 * the behavior is unspecified and may result in an
658 * exception.
659 *
660 * @param e the action event
661 * @see java.awt.event.ActionEvent
662 * @see java.awt.event.ActionListener
663 * @see java.awt.MenuItem#enableEvents
664 * @since 1.1
665 */
666 protected void processActionEvent(ActionEvent e) {
667 ActionListener listener = actionListener;
668 if (listener != null) {
669 listener.actionPerformed(e);
670 }
671 }
672
673 /**
674 * Returns a string representing the state of this <code>MenuItem</code>.
675 * This method is intended to be used only for debugging purposes, and the
676 * content and format of the returned string may vary between
677 * implementations. The returned string may be empty but may not be
678 * <code>null</code>.
679 *
680 * @return the parameter string of this menu item
681 */
682 public String paramString() {
683 String str = ",label=" + label;
684 if (shortcut != null) {
|