當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。