1. /*
  2. * @(#)MenuKeyEvent.java 1.13 03/12/19
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package javax.swing.event;
  8. import javax.swing.MenuElement;
  9. import javax.swing.MenuSelectionManager;
  10. import java.util.EventObject;
  11. import java.awt.event.KeyEvent;
  12. import java.awt.Component;
  13. /**
  14. * MenuKeyEvent is used to notify interested parties that
  15. * the menu element has received a KeyEvent forwarded to it
  16. * in a menu tree.
  17. * <p>
  18. * <strong>Warning:</strong>
  19. * Serialized objects of this class will not be compatible with
  20. * future Swing releases. The current serialization support is
  21. * appropriate for short term storage or RMI between applications running
  22. * the same version of Swing. As of 1.4, support for long term storage
  23. * of all JavaBeans<sup><font size="-2">TM</font></sup>
  24. * has been added to the <code>java.beans</code> package.
  25. * Please see {@link java.beans.XMLEncoder}.
  26. *
  27. * @version 1.13 12/19/03
  28. * @author Georges Saab
  29. */
  30. public class MenuKeyEvent extends KeyEvent {
  31. private MenuElement path[];
  32. private MenuSelectionManager manager;
  33. /**
  34. * Constructs a MenuKeyEvent object.
  35. *
  36. * @param source the Component that originated the event
  37. * (typically <code>this</code>)
  38. * @param id an int specifying the type of event, as defined
  39. * in {@link java.awt.event.KeyEvent}
  40. * @param when a long identifying the time the event occurred
  41. * @param modifiers an int specifying any modifier keys held down,
  42. * as specified in {@link java.awt.event.InputEvent}
  43. * @param keyCode an int specifying the specific key that was pressed
  44. * @param keyChar a char specifying the key's character value, if any
  45. * -- null if the key has no character value
  46. * @param p an array of MenuElement objects specifying a path
  47. * to a menu item affected by the drag
  48. * @param m a MenuSelectionManager object that handles selections
  49. */
  50. public MenuKeyEvent(Component source, int id, long when, int modifiers,
  51. int keyCode, char keyChar,
  52. MenuElement p[], MenuSelectionManager m) {
  53. super(source, id, when, modifiers, keyCode, keyChar);
  54. path = p;
  55. manager = m;
  56. }
  57. /**
  58. * Returns the path to the menu item referenced by this event.
  59. *
  60. * @return an array of MenuElement objects representing the path value
  61. */
  62. public MenuElement[] getPath() {
  63. return path;
  64. }
  65. /**
  66. * Returns the current menu selection manager.
  67. *
  68. * @return a MenuSelectionManager object
  69. */
  70. public MenuSelectionManager getMenuSelectionManager() {
  71. return manager;
  72. }
  73. }