KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > swingwtx > swing > JMenuItem


1 /*
2    SwingWT
3    Copyright(c)2003-2004, R. Rawson-Tetley
4
5    For more information on distributing and using this program, please
6    see the accompanying "COPYING" file.
7
8    Contact me by electronic mail: bobintetley@users.sourceforge.net
9
10    $Log: JMenuItem.java,v $
11    Revision 1.11 2004/03/30 10:42:46 bobintetley
12    Many minor bug fixes, event improvements by Dan Naab. Full swing.Icon support
13
14    Revision 1.10 2004/01/26 08:11:00 bobintetley
15    Many bugfixes and addition of SwingSet
16
17    Revision 1.9 2004/01/23 08:05:10 bobintetley
18    JComboBox fixes and better Action implementation
19
20    Revision 1.8 2004/01/20 09:17:15 bobintetley
21    Menu class overhaul for compatibility, Action support and thread safety
22
23    Revision 1.7 2003/12/15 18:29:57 bobintetley
24    Changed setParent() method to setSwingWTParent() to avoid conflicts with applications
25
26    Revision 1.6 2003/12/14 09:13:38 bobintetley
27    Added CVS log to source headers
28
29 */

30
31
32 package swingwtx.swing;
33
34 import org.eclipse.swt.widgets.*;
35 import org.eclipse.swt.*;
36
37 public class JMenuItem extends JSWTMenuComponent implements ButtonModel {
38     
39     private Shell shell = null;
40     
41     public JMenuItem() {setModel(this);}
42     public JMenuItem(Action a) { setAction(a); setModel(this); }
43     public JMenuItem(Icon icon) { this("", icon); }
44     public JMenuItem(String JavaDoc text) {this(text, null); }
45     public JMenuItem(String JavaDoc text, Icon icon) { pText = text; pImage = icon; setModel(this);}
46     public JMenuItem(String JavaDoc text, int mnemonic) { pText = text; setMnemonic(mnemonic); setModel(this);}
47     
48     public void setAction(Action a) {
49         if (a.getValue(Action.ACCELERATOR_KEY) != null) {
50             if (a.getValue(Action.ACCELERATOR_KEY) != null)
51                 setAccelerator((KeyStroke) a.getValue(Action.ACCELERATOR_KEY));
52         }
53         super.setAction(a);
54     }
55     
56     public void setSwingWTParent(Menu parent, Shell shell) throws Exception JavaDoc {
57         this.shell = shell;
58         peer = new MenuItem(parent, SWT.PUSH);
59     }
60     
61     public boolean isSelected() {
62         return false;
63     }
64     
65     public void setSelected(boolean b) {
66     }
67     
68     public Object JavaDoc[] getSelectedObjects() {
69         return null;
70     }
71     
72     public boolean isArmed() {
73         return false;
74     }
75     
76     public boolean isPressed() {
77         return isSelected();
78     }
79     
80     public boolean isRollover() {
81         return false;
82     }
83     
84     public void setArmed(boolean b) {
85     }
86     
87     public void setPressed(boolean b) {
88     }
89     
90     public void setRollover(boolean b) {
91     }
92     
93 }
94
Popular Tags