当前位置: 首页>>代码示例>>Java>>正文


Java MenuItem.setShortcut方法代码示例

本文整理汇总了Java中java.awt.MenuItem.setShortcut方法的典型用法代码示例。如果您正苦于以下问题:Java MenuItem.setShortcut方法的具体用法?Java MenuItem.setShortcut怎么用?Java MenuItem.setShortcut使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.MenuItem的用法示例。


在下文中一共展示了MenuItem.setShortcut方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addMenuItems

import java.awt.MenuItem; //导入方法依赖的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);
        }
    }
 
开发者ID:Julien35,项目名称:dev-courses,代码行数:15,代码来源:DatabaseManager.java

示例2: initFileMenu

import java.awt.MenuItem; //导入方法依赖的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;
}
 
开发者ID:gurkenlabs,项目名称:litiengine,代码行数:35,代码来源:Program.java

示例3: addMenuItems

import java.awt.MenuItem; //导入方法依赖的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);
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:22,代码来源:DatabaseManager.java

示例4: addMenuItems

import java.awt.MenuItem; //导入方法依赖的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);
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:22,代码来源:DatabaseManager.java

示例5: initViewMenu

import java.awt.MenuItem; //导入方法依赖的package包/类
private static Menu initViewMenu() {
  Menu mnView = new Menu(Resources.get("menu_view"));

  CheckboxMenuItem snapToGrid = new CheckboxMenuItem(Resources.get("menu_snapGrid"));
  snapToGrid.setState(userPreferences.isSnapGrid());
  EditorScreen.instance().getMapComponent().snapToGrid = snapToGrid.getState();
  snapToGrid.addItemListener(e -> {
    EditorScreen.instance().getMapComponent().snapToGrid = snapToGrid.getState();
    userPreferences.setSnapGrid(snapToGrid.getState());
  });

  CheckboxMenuItem renderGrid = new CheckboxMenuItem(Resources.get("menu_renderGrid"));
  renderGrid.setState(userPreferences.isShowGrid());
  EditorScreen.instance().getMapComponent().renderGrid = renderGrid.getState();
  renderGrid.setShortcut(new MenuShortcut(KeyEvent.VK_G));
  renderGrid.addItemListener(e -> {
    EditorScreen.instance().getMapComponent().renderGrid = renderGrid.getState();
    userPreferences.setShowGrid(renderGrid.getState());
  });

  CheckboxMenuItem renderCollision = new CheckboxMenuItem(Resources.get("menu_renderCollisionBoxes"));
  renderCollision.setState(userPreferences.isRenderBoundingBoxes());
  EditorScreen.instance().getMapComponent().renderCollisionBoxes = renderCollision.getState();
  renderCollision.setShortcut(new MenuShortcut(KeyEvent.VK_H));
  renderCollision.addItemListener(e -> {
    EditorScreen.instance().getMapComponent().renderCollisionBoxes = renderCollision.getState();
    userPreferences.setRenderBoundingBoxes(renderCollision.getState());
  });

  MenuItem setGrid = new MenuItem(Resources.get("menu_gridSize"));
  setGrid.addActionListener(a -> {
    GridEditPanel panel = new GridEditPanel(EditorScreen.instance().getMapComponent().getGridSize());
    int option = JOptionPane.showConfirmDialog(null, panel, Resources.get("menu_gridSettings"), JOptionPane.DEFAULT_OPTION);
    if (option == JOptionPane.OK_OPTION) {
      EditorScreen.instance().getMapComponent().setGridSize(panel.getGridSize());
    }
  });

  MenuItem zoomIn = new MenuItem(Resources.get("menu_zoomIn"));
  zoomIn.setShortcut(new MenuShortcut(KeyEvent.VK_PLUS));
  zoomIn.addActionListener(a -> EditorScreen.instance().getMapComponent().zoomIn());

  MenuItem zoomOut = new MenuItem(Resources.get("menu_zoomOut"));
  zoomOut.setShortcut(new MenuShortcut(KeyEvent.VK_MINUS));
  zoomOut.addActionListener(a -> EditorScreen.instance().getMapComponent().zoomOut());

  mnView.add(snapToGrid);
  mnView.add(renderGrid);
  mnView.add(renderCollision);
  mnView.add(setGrid);
  mnView.addSeparator();
  mnView.add(zoomIn);
  mnView.add(zoomOut);

  return mnView;
}
 
开发者ID:gurkenlabs,项目名称:litiengine,代码行数:57,代码来源:Program.java

示例6: initMapMenu

import java.awt.MenuItem; //导入方法依赖的package包/类
private static Menu initMapMenu() {
  Menu mnMap = new Menu(Resources.get("menu_map"));

  MenuItem imp = new MenuItem(Resources.get("menu_import"));
  imp.addActionListener(a -> EditorScreen.instance().getMapComponent().importMap());

  MenuItem exp = new MenuItem(Resources.get("menu_export"));
  exp.addActionListener(a -> EditorScreen.instance().getMapComponent().exportMap());

  MenuItem del2 = new MenuItem(Resources.get("menu_removeMap"));
  del2.addActionListener(a -> EditorScreen.instance().getMapComponent().deleteMap());

  MenuItem mapProps = new MenuItem(Resources.get("menu_properties"));
  mapProps.setShortcut(new MenuShortcut(KeyEvent.VK_M));
  mapProps.addActionListener(a -> {
    if (EditorScreen.instance().getMapComponent().getMaps() == null || EditorScreen.instance().getMapComponent().getMaps().isEmpty()) {
      return;
    }

    MapPropertyPanel panel = new MapPropertyPanel();
    panel.bind(Game.getEnvironment().getMap());

    int option = JOptionPane.showConfirmDialog(null, panel, Resources.get("menu_mapProperties"), JOptionPane.OK_CANCEL_OPTION);
    if (option == JOptionPane.OK_OPTION) {
      panel.saveChanges();

      final String colorProp = Game.getEnvironment().getMap().getCustomProperty(MapProperty.AMBIENTCOLOR);
      try {
        if (Game.getEnvironment().getMap().getCustomProperty(MapProperty.AMBIENTALPHA) != null) {
          int alpha = Integer.parseInt(Game.getEnvironment().getMap().getCustomProperty(MapProperty.AMBIENTALPHA));
          Game.getEnvironment().getAmbientLight().setAlpha(alpha);
        }

        if (colorProp != null && !colorProp.isEmpty()) {
          Color ambientColor = Color.decode(colorProp);
          Game.getEnvironment().getAmbientLight().setColor(ambientColor);
        }
      } catch (final NumberFormatException nfe) {
        log.log(Level.SEVERE, nfe.getLocalizedMessage(), nfe);
      }

      EditorScreen.instance().getMapComponent().loadMaps(EditorScreen.instance().getGameFile().getMaps());
      EditorScreen.instance().getMapComponent().loadEnvironment((Map) Game.getEnvironment().getMap());
      EditorScreen.instance().mapChanged();
    }
  });

  mnMap.add(imp);
  mnMap.add(exp);
  mnMap.add(del2);
  mnMap.addSeparator();
  mnMap.add(mapProps);

  return mnMap;
}
 
开发者ID:gurkenlabs,项目名称:litiengine,代码行数:56,代码来源:Program.java


注:本文中的java.awt.MenuItem.setShortcut方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。