KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > swing > MenuElement


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
9 import java.awt.*;
10 import java.awt.event.*;
11
12 /**
13  * Any component that can be placed into a menu should implement this interface.
14  * This interface is used by <code>MenuSelectionManager</code>
15  * to handle selection and navigation in menu hierarchies.
16  *
17  * @version 1.12 12/19/03
18  * @author Arnaud Weber
19  */

20
21 public interface MenuElement {
22     
23     /**
24      * Processes a mouse event. <code>event</code> is a <code>MouseEvent</code>
25      * with source being the receiving element's component.
26      * <code>path</code> is the path of the receiving element in the menu
27      * hierarchy including the receiving element itself.
28      * <code>manager</code> is the <code>MenuSelectionManager</code>
29      * for the menu hierarchy.
30      * This method should process the <code>MouseEvent</code> and change
31      * the menu selection if necessary
32      * by using <code>MenuSelectionManager</code>'s API
33      * Note: you do not have to forward the event to sub-components.
34      * This is done automatically by the <code>MenuSelectionManager</code>.
35      */

36     public void processMouseEvent(MouseEvent event,MenuElement JavaDoc path[],MenuSelectionManager JavaDoc manager);
37
38
39     /**
40      * Process a key event.
41      */

42     public void processKeyEvent(KeyEvent event,MenuElement JavaDoc path[],MenuSelectionManager JavaDoc manager);
43
44     /**
45      * Call by the <code>MenuSelectionManager</code> when the
46      * <code>MenuElement</code> is added or remove from
47      * the menu selection.
48      */

49     public void menuSelectionChanged(boolean isIncluded);
50
51     /**
52      * This method should return an array containing the sub-elements for the receiving menu element
53      *
54      * @return an array of MenuElements
55      */

56     public MenuElement JavaDoc[] getSubElements();
57     
58     /**
59      * This method should return the java.awt.Component used to paint the receiving element.
60      * The returned component will be used to convert events and detect if an event is inside
61      * a MenuElement's component.
62      *
63      * @return the Component value
64      */

65     public Component getComponent();
66 }
67
68
Popular Tags