當前位置: 首頁>>代碼示例>>Java>>正文


Java Menu.addSeparator方法代碼示例

本文整理匯總了Java中java.awt.Menu.addSeparator方法的典型用法代碼示例。如果您正苦於以下問題:Java Menu.addSeparator方法的具體用法?Java Menu.addSeparator怎麽用?Java Menu.addSeparator使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.awt.Menu的用法示例。


在下文中一共展示了Menu.addSeparator方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: initProjectMenu

import java.awt.Menu; //導入方法依賴的package包/類
private static Menu initProjectMenu() {
  Menu mnProject = new Menu(Resources.get("menu_project"));

  CheckboxMenuItem compress = new CheckboxMenuItem(Resources.get("menu_compressProjectFile"));
  compress.setState(userPreferences.isCompressFile());
  compress.addItemListener(e -> userPreferences.setCompressFile(compress.getState()));

  CheckboxMenuItem sync = new CheckboxMenuItem(Resources.get("menu_syncMaps"));
  sync.setState(userPreferences.isSyncMaps());
  sync.addItemListener(e -> userPreferences.setSyncMaps(sync.getState()));

  MenuItem importSpriteFile = new MenuItem(Resources.get("menu_assets_importSpriteFile"));
  importSpriteFile.addActionListener(a -> EditorScreen.instance().importSpriteFile());

  MenuItem importSprite = new MenuItem(Resources.get("menu_assets_importSprite"));
  importSprite.addActionListener(a -> EditorScreen.instance().importSprites());

  mnProject.add(importSprite);
  mnProject.add(importSpriteFile);
  mnProject.addSeparator();
  mnProject.add(compress);
  mnProject.add(sync);

  return mnProject;
}
 
開發者ID:gurkenlabs,項目名稱:litiengine,代碼行數:26,代碼來源:Program.java

示例2: addMenuItems

import java.awt.Menu; //導入方法依賴的package包/類
/**
 * Method declaration
 *
 *
 * @param f
 * @param m
 */
private void addMenuItems(Menu f, String[] m) {

    for (int i = 0; i < m.length; i++) {
        if (m[i].equals("-")) {
            f.addSeparator();
        } else {
            MenuItem item = new MenuItem(m[i]);

            item.addActionListener(this);
            f.add(item);
        }
    }
}
 
開發者ID:anhnv-3991,項目名稱:VoltDB,代碼行數:21,代碼來源:Transfer.java

示例3: initFileMenu

import java.awt.Menu; //導入方法依賴的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

示例4: addMenuItems

import java.awt.Menu; //導入方法依賴的package包/類
/**
 * Method declaration
 *
 *
 * @param f
 * @param m
 */
private void addMenuItems(Menu f, String m[]) {

    for (int i = 0; i < m.length; i++) {
        if (m[i].equals("-")) {
            f.addSeparator();
        } else {
            MenuItem item = new MenuItem(m[i]);

            item.addActionListener(this);
            f.add(item);
        }
    }
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:21,代碼來源:Transfer.java

示例5: initViewMenu

import java.awt.Menu; //導入方法依賴的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.Menu; //導入方法依賴的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

示例7: setupTray

import java.awt.Menu; //導入方法依賴的package包/類
public static synchronized void setupTray() {
	popup.removeAll();

	if (pausedTime.get() != -1L && pausedTime.get() > System.currentTimeMillis()) {
		MenuItem resume = new MenuItem("Resume");
		resume.addActionListener(new PauseActionListener(-1L));
		popup.add(resume);
	} else {
		pausedTime.set(-1);
		MenuItem recheck = new MenuItem("Force Recheck");
		recheck.addActionListener(new ForceRecheckListener());
		popup.add(recheck);
		
		Menu pauseMenu = new Menu("Pause");
		
		MenuItem pause = new MenuItem("Pause");
		pause.addActionListener(new PauseActionListener(365 * 24 * 60 * 60 * 1000L));
		pauseMenu.add(pause);
		
		MenuItem pause1 = new MenuItem("Pause - 1 hour");
		pause1.addActionListener(new PauseActionListener(1 * 60 * 60 * 1000L));
		pauseMenu.add(pause1);
		
		MenuItem pause3 = new MenuItem("Pause - 3 hours");
		pause3.addActionListener(new PauseActionListener(3 * 60 * 60 * 1000L));
		pauseMenu.add(pause3);
		
		MenuItem pause6 = new MenuItem("Pause - 6 hours");
		pause6.addActionListener(new PauseActionListener(6 * 60 * 60 * 1000L));
		pauseMenu.add(pause6);
		
		MenuItem pause12 = new MenuItem("Pause - 12 hours");
		pause12.addActionListener(new PauseActionListener(12 * 60 * 60 * 1000L));
		pauseMenu.add(pause12);

		popup.add(pauseMenu);
	}

	Menu serverList = new Menu("Server List");
	MenuItem addServer = new MenuItem("Add Server");
	addServer.addActionListener(new ServerEntryListener());
	serverList.add(addServer);
	serverList.addSeparator();

	popup.add(serverList);

	for (ServerEntry entry : servers) {
		Menu server = new Menu(entry.getAlias());
		
		MenuItem edit = new MenuItem("Edit");
		server.add(edit);
		edit.addActionListener(new ServerEntryListener(entry));
		
		MenuItem remove = new MenuItem("Remove");
		server.add(remove);
		remove.addActionListener(new RemoveServerListener(entry, remove));

		serverList.add(server);
	}

	MenuItem exit = new MenuItem("Exit");
	exit.addActionListener(new ExitActionListener());
	popup.add(exit);
}
 
開發者ID:Afforess,項目名稱:sftp-sync,代碼行數:65,代碼來源:SFTPService.java


注:本文中的java.awt.Menu.addSeparator方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。