1. /*
  2. * @(#)MenuElement.java 1.12 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;
  8. import java.awt.*;
  9. import java.awt.event.*;
  10. /**
  11. * Any component that can be placed into a menu should implement this interface.
  12. * This interface is used by <code>MenuSelectionManager</code>
  13. * to handle selection and navigation in menu hierarchies.
  14. *
  15. * @version 1.12 12/19/03
  16. * @author Arnaud Weber
  17. */
  18. public interface MenuElement {
  19. /**
  20. * Processes a mouse event. <code>event</code> is a <code>MouseEvent</code>
  21. * with source being the receiving element's component.
  22. * <code>path</code> is the path of the receiving element in the menu
  23. * hierarchy including the receiving element itself.
  24. * <code>manager</code> is the <code>MenuSelectionManager</code>
  25. * for the menu hierarchy.
  26. * This method should process the <code>MouseEvent</code> and change
  27. * the menu selection if necessary
  28. * by using <code>MenuSelectionManager</code>'s API
  29. * Note: you do not have to forward the event to sub-components.
  30. * This is done automatically by the <code>MenuSelectionManager</code>.
  31. */
  32. public void processMouseEvent(MouseEvent event,MenuElement path[],MenuSelectionManager manager);
  33. /**
  34. * Process a key event.
  35. */
  36. public void processKeyEvent(KeyEvent event,MenuElement path[],MenuSelectionManager manager);
  37. /**
  38. * Call by the <code>MenuSelectionManager</code> when the
  39. * <code>MenuElement</code> is added or remove from
  40. * the menu selection.
  41. */
  42. public void menuSelectionChanged(boolean isIncluded);
  43. /**
  44. * This method should return an array containing the sub-elements for the receiving menu element
  45. *
  46. * @return an array of MenuElements
  47. */
  48. public MenuElement[] getSubElements();
  49. /**
  50. * This method should return the java.awt.Component used to paint the receiving element.
  51. * The returned component will be used to convert events and detect if an event is inside
  52. * a MenuElement's component.
  53. *
  54. * @return the Component value
  55. */
  56. public Component getComponent();
  57. }