1. /*
  2. * @(#)MenuKeyEvent.java 1.8 01/11/29
  3. *
  4. * Copyright 2002 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 appropriate
  21. * for short term storage or RMI between applications running the same
  22. * version of Swing. A future release of Swing will provide support for
  23. * long term persistence.
  24. *
  25. * @version 1.8 11/29/01
  26. * @author Georges Saab
  27. */
  28. public class MenuKeyEvent extends KeyEvent {
  29. private MenuElement path[];
  30. private MenuSelectionManager manager;
  31. /**
  32. * Constructs a MenuKeyEvent object.
  33. *
  34. * @param source the Component that originated the event
  35. * (typically <code>this</code>)
  36. * @param id an int specifying the type of event, as defined
  37. * in {@link java.awt.event.KeyEvent}
  38. * @param when a long identifying the time the event occurred
  39. * @param modifiers an int specifying any modifier keys held down,
  40. * as specified in {@link java.awt.event.InputEvent}
  41. * @param keyCode an int specifying the specific key that was pressed
  42. * @param keyChar a char specifying the key's character value, if any
  43. * -- null if the key has no character value
  44. * @param p an array of MenuElement objects specifying a path
  45. * to a menu item affected by the drag
  46. * @param m a MenuSelectionManager object that handles selections
  47. */
  48. public MenuKeyEvent(Component source, int id, long when, int modifiers,
  49. int keyCode, char keyChar,
  50. MenuElement p[], MenuSelectionManager m) {
  51. super(source, id, when, modifiers, keyCode, keyChar);
  52. path = p;
  53. manager = m;
  54. }
  55. /**
  56. * Returns the path to the menu item referenced by this event.
  57. *
  58. * @return an array of MenuElement objects representing the path value
  59. */
  60. public MenuElement[] getPath() {
  61. return path;
  62. }
  63. /**
  64. * Returns the current menu selection manager.
  65. *
  66. * @return a MenuSelectionManager object
  67. */
  68. public MenuSelectionManager getMenuSelectionManager() {
  69. return manager;
  70. }
  71. }