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