java.awt.MenuItem.setShortcut()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(4.3k)|赞(0)|评价(0)|浏览(244)

本文整理了Java中java.awt.MenuItem.setShortcut()方法的一些代码示例,展示了MenuItem.setShortcut()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MenuItem.setShortcut()方法的具体详情如下:
包路径:java.awt.MenuItem
类名称:MenuItem
方法名:setShortcut

暂无

代码示例

代码示例来源:origin: com.dorkbox/SystemTray

@Override
  public
  void run() {
    _native.setShortcut(new MenuShortcut(vKey));
  }
});

代码示例来源:origin: stackoverflow.com

public boolean onMenuOpened(int featureid, Menu menu)
 {
   menu.clear();
   if (!editable)
   {
     MenuItem itemAdd = menu.add(0, REASSIGN, Menu.NONE, context.getString(R.string.reassign));
     MenuItem itemMod = menu.add(1, EDIT, Menu.NONE, context.getString(R.string.modify));
     MenuItem itemDel = menu.add(2, DELETE, Menu.NONE, context.getString(R.string.delete));
     itemAdd.setShortcut('0', 'a');
     itemMod.setShortcut('1', 'm');
     itemDel.setShortcut('2', 'd');
   }
   else
   {
     MenuItem itemSave = menu.add(3, SAVE, Menu.NONE, context.getString(R.string.savechanges));
     itemSave.setShortcut('0', 'S');
   }
   return true;
 }

代码示例来源:origin: stackoverflow.com

this.openFile.setShortcut(new MenuShortcut(KeyEvent.VK_O, false)); 
this.saveFile.setShortcut(new MenuShortcut(KeyEvent.VK_S, false));
this.close.setShortcut(new MenuShortcut(KeyEvent.VK_F4, false));

代码示例来源:origin: stackoverflow.com

this.openFile.setShortcut(new MenuShortcut(KeyEvent.VK_O, false)); // set a keyboard shortcut
this.saveFile.setShortcut(new MenuShortcut(KeyEvent.VK_S, false));
this.close.setShortcut(new MenuShortcut(KeyEvent.VK_F4, false));

代码示例来源:origin: stackoverflow.com

normalFont.addActionListener(this);
openFile.addActionListener(this);
openFile.setShortcut(new MenuShortcut(KeyEvent.VK_0, false));
file.add(this.openFile);
saveFile.setLabel("Save");
saveFile.addActionListener(this);
saveFile.setShortcut(new MenuShortcut(KeyEvent.VK_S, false));
file.add(this.saveFile);
close.setLabel("Close");
close.setShortcut(new MenuShortcut(KeyEvent.VK_F4, false));
close.addActionListener(this);
file.add(this.close);

代码示例来源:origin: org.scijava/scijava-ui-awt

private void
  assignProperties(final MenuItem menuItem, final ShadowMenu shadow)
{
  final Accelerator acc = shadow.getMenuEntry().getAccelerator();
  if (acc != null) {
    final int code = acc.getKeyCode().getCode();
    final boolean shift = acc.getModifiers().isShiftDown();
    final MenuShortcut shortcut = new MenuShortcut(code, shift);
    menuItem.setShortcut(shortcut);
  }
  final ModuleInfo info = shadow.getModuleInfo();
  if (info != null) menuItem.setEnabled(info.isEnabled());
}

代码示例来源:origin: gurkenlabs/litiengine

private static Menu initFileMenu() {
 Menu mnFile = new Menu(Resources.strings().get("menu_file"));
 MenuItem create = new MenuItem(Resources.strings().get("menu_createProject"));
 create.setShortcut(new MenuShortcut(KeyEvent.VK_N));
 create.addActionListener(a -> EditorScreen.instance().create());
 MenuItem load = new MenuItem(Resources.strings().get("menu_loadProject"));
 load.setShortcut(new MenuShortcut(KeyEvent.VK_O));
 load.addActionListener(a -> EditorScreen.instance().load());
 MenuItem save = new MenuItem(Resources.strings().get("menu_save"));
 save.setShortcut(new MenuShortcut(KeyEvent.VK_S));
 save.addActionListener(a -> EditorScreen.instance().save(false));
 MenuItem saveAs = new MenuItem(Resources.strings().get("menu_saveAs"));
 saveAs.addActionListener(a -> EditorScreen.instance().save(true));
 MenuItem exit = new MenuItem(Resources.strings().get("menu_exit"));
 exit.setShortcut(new MenuShortcut(KeyEvent.VK_Q));
 exit.addActionListener(a -> System.exit(0));
 mnFile.add(load);
 mnFile.add(create);
 mnFile.add(save);
 mnFile.add(saveAs);
 mnFile.addSeparator();
 recentFiles = new Menu(Resources.strings().get("menu_recentFiles"));
 loadRecentFiles();
 mnFile.add(recentFiles);
 mnFile.addSeparator();
 mnFile.add(exit);
 return mnFile;
}

代码示例来源:origin: gurkenlabs/litiengine

saveMapSnapshot.setShortcut(new MenuShortcut(KeyEvent.VK_ENTER));
saveMapSnapshot.addActionListener(a -> EditorScreen.instance().saveMapSnapshot());
mapProps.setShortcut(new MenuShortcut(KeyEvent.VK_M));
mapProps.addActionListener(a -> {
 if (EditorScreen.instance().getMapComponent().getMaps() == null || EditorScreen.instance().getMapComponent().getMaps().isEmpty()) {

代码示例来源:origin: gurkenlabs/litiengine

zoomIn.setShortcut(new MenuShortcut(KeyEvent.VK_PLUS));
zoomIn.addActionListener(a -> EditorScreen.instance().getMapComponent().zoomIn());
zoomOut.setShortcut(new MenuShortcut(KeyEvent.VK_MINUS));
zoomOut.addActionListener(a -> EditorScreen.instance().getMapComponent().zoomOut());

相关文章