5 // Created by Lutz Mueller on 5/21/07.
8 // Copyright (C) 2007 Lutz Mueller
10 // This program is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
15 // This program is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
20 // You should have received a copy of the GNU General Public License
21 // along with this program. If not, see <http://www.gnu.org/licenses/>.
26 import java
.awt
.event
.*;
30 public class MenuItemWidget
extends aButton
{
34 @SuppressWarnings("unchecked")
35 public MenuItemWidget(StringTokenizer params
)
37 menuitem
= new JMenuItem();
38 jcomponent
= menuitem
;
43 id
= params
.nextToken();
44 action
= params
.nextToken();
46 menuitem
.setText(Base64Coder
.decodeString(params
.nextToken()));
48 gsObject
.widgets
.put(id
, this);
50 ActionListener listener
= new ActionListener() {
51 public void actionPerformed(ActionEvent e
)
55 guiserver
.out
.println("("+ action
+ " \"" + id
+ "\")");
56 guiserver
.out
.flush();
61 menuitem
.addActionListener(listener
);
64 public void setAccelerator(StringTokenizer tokens
)
66 String keystroke
= Base64Coder
.decodeString(tokens
.nextToken());
68 //System.out.println("setting accelerator: " + keystroke);
70 menuitem
.setAccelerator(KeyStroke
.getKeyStroke(keystroke
));
73 // <modifiers>* (<typedID> | <pressedReleasedID>)
74 // modifiers := shift | control | ctrl | meta | alt | button1 | button2 | button3
75 // typedID := typed <typedKey>
76 // typedKey := string of length 1 giving Unicode character.
77 // pressedReleasedID := (pressed | released) key
78 // key := KeyEvent key code name, i.e. the name following "VK_".
84 // "alt shift released X"
87 // note that alt on MacOS X is the option key
88 // for letters use uppercase, keys care added in menu item display automatically