本文整理汇总了Java中java.awt.MenuShortcut类的典型用法代码示例。如果您正苦于以下问题:Java MenuShortcut类的具体用法?Java MenuShortcut怎么用?Java MenuShortcut使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MenuShortcut类属于java.awt包,在下文中一共展示了MenuShortcut类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addMenuItems
import java.awt.MenuShortcut; //导入依赖的package包/类
void addMenuItems(Menu f, String[] m) {
for (int i = 0; i < m.length; i++) {
MenuItem item = new MenuItem(m[i].substring(1));
char c = m[i].charAt(0);
if (c != '-') {
item.setShortcut(new MenuShortcut(c));
}
item.addActionListener(this);
f.add(item);
}
}
示例2: main
import java.awt.MenuShortcut; //导入依赖的package包/类
public static void main(String[] args) {
Container container = new Container();
Panel panel = new Panel();
Menu menu = new Menu(); //!!! its not component
TextField textField = new TextField();
container.add(textField);
Window win = new Window(null);
win.pack();
menu.setShortcut(new MenuShortcut(12));
new MenuItem("label", new MenuShortcut(33, true));
Menu file = new Menu("File");
MenuItem print;
file.add(print = new MenuItem("Print", new MenuShortcut('p')));
}
示例3: instantiate
import java.awt.MenuShortcut; //导入依赖的package包/类
@Override
protected Expression instantiate(Object oldInstance, Encoder enc) {
MenuShortcut shortcut = (MenuShortcut) oldInstance;
int keyCode = shortcut.getKey();
boolean useShiftModifier = shortcut.usesShiftModifier();
return new Expression(shortcut, shortcut.getClass(), BeansUtils.NEW,
new Object[] { keyCode, useShiftModifier });
}
示例4: initFileMenu
import java.awt.MenuShortcut; //导入依赖的package包/类
private static Menu initFileMenu() {
Menu mnFile = new Menu(Resources.get("menu_file"));
MenuItem create = new MenuItem(Resources.get("menu_createProject"));
create.setShortcut(new MenuShortcut(KeyEvent.VK_N));
create.addActionListener(a -> EditorScreen.instance().create());
MenuItem load = new MenuItem(Resources.get("menu_loadProject"));
load.setShortcut(new MenuShortcut(KeyEvent.VK_O));
load.addActionListener(a -> EditorScreen.instance().load());
MenuItem save = new MenuItem(Resources.get("menu_save"));
save.setShortcut(new MenuShortcut(KeyEvent.VK_S));
save.addActionListener(a -> EditorScreen.instance().save(false));
MenuItem saveAs = new MenuItem(Resources.get("menu_saveAs"));
saveAs.addActionListener(a -> EditorScreen.instance().save(true));
MenuItem exit = new MenuItem(Resources.get("menu_exit"));
exit.setShortcut(new MenuShortcut(KeyEvent.VK_Q));
exit.addActionListener(a -> Game.terminate());
mnFile.add(load);
mnFile.add(create);
mnFile.add(save);
mnFile.add(saveAs);
mnFile.addSeparator();
recentFiles = new Menu(Resources.get("menu_recentFiles"));
loadRecentFiles();
mnFile.add(recentFiles);
mnFile.addSeparator();
mnFile.add(exit);
return mnFile;
}
示例5: setLabel
import java.awt.MenuShortcut; //导入依赖的package包/类
public void setLabel(String label, char keyChar, int keyCode, int modifiers) {
int keyMask = modifiers;
if (keyCode == KeyEvent.VK_UNDEFINED) {
MenuShortcut shortcut = ((MenuItem)getTarget()).getShortcut();
if (shortcut != null) {
keyCode = shortcut.getKey();
keyMask |= InputEvent.META_MASK;
if (shortcut.usesShiftModifier()) {
keyMask |= InputEvent.SHIFT_MASK;
}
}
}
if (label == null) {
label = "";
}
// <rdar://problem/3654824>
// Native code uses a keyChar of 0 to indicate that the
// keyCode should be used to generate the shortcut. Translate
// CHAR_UNDEFINED into 0.
if (keyChar == KeyEvent.CHAR_UNDEFINED) {
keyChar = 0;
}
nativeSetLabel(getModel(), label, keyChar, keyCode, keyMask);
}
示例6: addMenuItems
import java.awt.MenuShortcut; //导入依赖的package包/类
/**
* Method declaration
*
*
* @param f
* @param m
*/
void addMenuItems(Menu f, String m[]) {
for (int i = 0; i < m.length; i++) {
MenuItem item = new MenuItem(m[i].substring(1));
char c = m[i].charAt(0);
if (c != '-') {
item.setShortcut(new MenuShortcut(c));
}
item.addActionListener(this);
f.add(item);
}
}
示例7: addMenuItems
import java.awt.MenuShortcut; //导入依赖的package包/类
/**
* Method declaration
*
*
* @param f
* @param m
*/
void addMenuItems(Menu f, String[] m) {
for (int i = 0; i < m.length; i++) {
MenuItem item = new MenuItem(m[i].substring(1));
char c = m[i].charAt(0);
if (c != '-') {
item.setShortcut(new MenuShortcut(c));
}
item.addActionListener(this);
f.add(item);
}
}
示例8: setLabel
import java.awt.MenuShortcut; //导入依赖的package包/类
public void setLabel(String label, char keyChar, int keyCode, int modifiers) {
int keyMask = modifiers;
if (keyCode == KeyEvent.VK_UNDEFINED) {
MenuShortcut shortcut = ((MenuItem)getTarget()).getShortcut();
if (shortcut != null) {
keyCode = shortcut.getKey();
keyMask |= InputEvent.META_MASK;
if (shortcut.usesShiftModifier()) {
keyMask |= InputEvent.SHIFT_MASK;
}
}
}
if (label == null) {
label = "";
}
// <rdar://problem/3654824>
// Native code uses a keyChar of 0 to indicate that the
// keyCode should be used to generate the shortcut. Translate
// CHAR_UNDEFINED into 0.
if (keyChar == KeyEvent.CHAR_UNDEFINED) {
keyChar = 0;
}
final String finalLabel = label;
final char finalKeyChar = keyChar;
final int finalKeyCode = keyCode;
final int finalKeyMask = keyMask;
execute(ptr -> nativeSetLabel(ptr, finalLabel, finalKeyChar,
finalKeyCode, finalKeyMask));
}
示例9: setLabel
import java.awt.MenuShortcut; //导入依赖的package包/类
@SuppressWarnings("deprecation")
public void setLabel(String label, char keyChar, int keyCode, int modifiers) {
int keyMask = modifiers;
if (keyCode == KeyEvent.VK_UNDEFINED) {
MenuShortcut shortcut = ((MenuItem)getTarget()).getShortcut();
if (shortcut != null) {
keyCode = shortcut.getKey();
keyMask |= InputEvent.META_MASK;
if (shortcut.usesShiftModifier()) {
keyMask |= InputEvent.SHIFT_MASK;
}
}
}
if (label == null) {
label = "";
}
// <rdar://problem/3654824>
// Native code uses a keyChar of 0 to indicate that the
// keyCode should be used to generate the shortcut. Translate
// CHAR_UNDEFINED into 0.
if (keyChar == KeyEvent.CHAR_UNDEFINED) {
keyChar = 0;
}
final String finalLabel = label;
final char finalKeyChar = keyChar;
final int finalKeyCode = keyCode;
final int finalKeyMask = keyMask;
execute(ptr -> nativeSetLabel(ptr, finalLabel, finalKeyChar,
finalKeyCode, finalKeyMask));
}
示例10: addItem
import java.awt.MenuShortcut; //导入依赖的package包/类
public void addItem (MenuItem item)
{
int key = 0;
boolean shiftModifier = false;
MenuShortcut ms = item.getShortcut ();
if (ms != null)
{
key = ms.getKey ();
shiftModifier = ms.usesShiftModifier ();
}
addItem ((MenuItemPeer) item.getPeer (), key, shiftModifier);
}
示例11: instantiate
import java.awt.MenuShortcut; //导入依赖的package包/类
@Override
@SuppressWarnings("boxing")
protected Expression instantiate(Object oldInstance, Encoder enc) {
MenuShortcut shortcut = (MenuShortcut) oldInstance;
int keyCode = shortcut.getKey();
boolean useShiftModifier = shortcut.usesShiftModifier();
return new Expression(shortcut, shortcut.getClass(),
Statement.CONSTRUCTOR_NAME, new Object[] {keyCode, useShiftModifier});
}
示例12: registerAwtPDs
import java.awt.MenuShortcut; //导入依赖的package包/类
private static void registerAwtPDs() {
delegates.put(Choice.class, new AwtChoicePersistenceDelegate());
delegates.put(Color.class, new AwtColorPersistenceDelegate());
delegates.put(Container.class,
new AwtContainerPersistenceDelegate());
delegates.put(Component.class,
new AwtComponentPersistenceDelegate());
delegates.put(Cursor.class, new AwtCursorPersistenceDelegate());
delegates.put(Dimension.class,
new AwtDimensionPersistenceDelegate());
delegates.put(Font.class, new AwtFontPersistenceDelegate());
delegates.put(Insets.class, new AwtInsetsPersistenceDelegate());
delegates.put(List.class, new AwtListPersistenceDelegate());
delegates.put(Menu.class, new AwtMenuPersistenceDelegate());
delegates.put(MenuBar.class, new AwtMenuBarPersistenceDelegate());
delegates.put(MenuShortcut.class,
new AwtMenuShortcutPersistenceDelegate());
delegates.put(Point.class, new AwtPointPersistenceDelegate());
delegates.put(Rectangle.class,
new AwtRectanglePersistenceDelegate());
delegates.put(SystemColor.class,
new AwtSystemColorPersistenceDelegate());
delegates.put(TextAttribute.class,
new AwtFontTextAttributePersistenceDelegate());
delegates.put(ScrollPane.class,
new AwtScrollPanePersistenceDelegate());
}
示例13: instantiate
import java.awt.MenuShortcut; //导入依赖的package包/类
@Override
protected Expression instantiate(Object oldInstance, Encoder enc)
{
MenuShortcut shortcut = (MenuShortcut) oldInstance;
int keyCode = shortcut.getKey();
boolean useShiftModifier = shortcut.usesShiftModifier();
return new Expression(shortcut, shortcut.getClass(), BeansUtils.NEW, new Object[] { keyCode, useShiftModifier });
}
示例14: getMenu
import java.awt.MenuShortcut; //导入依赖的package包/类
private static PopupMenu getMenu()
{
menu = new PopupMenu(ZAYF_TRAY_TOOLTIP);
exitItem = new MenuItem("exit", new MenuShortcut('x'));
menu.add(exitItem);
return menu;
}