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


Java CheckboxMenuItem.addItemListener方法代碼示例

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


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

示例1: initProjectMenu

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

import java.awt.CheckboxMenuItem; //導入方法依賴的package包/類
private PopupMenu makePopupMenu() {
  PopupMenu popup = new PopupMenu();
  ActionListener rmbListener = new TrayActionRMBListener();
  // Enable or disable embedded HTTP server:
  enableHttpServerItem = new CheckboxMenuItem(Tools.getLabel(messages.getString("tray_menu_enable_server")));
  enableHttpServerItem.setState(httpServer != null && httpServer.isRunning());
  enableHttpServerItem.addItemListener(new TrayActionItemListener());
  popup.add(enableHttpServerItem);
  // Check clipboard text:
  MenuItem checkClipboardItem =
          new MenuItem(Tools.getLabel(messages.getString("guiMenuCheckClipboard")));
  checkClipboardItem.addActionListener(rmbListener);
  popup.add(checkClipboardItem);
  // Open main window:
  MenuItem restoreItem = new MenuItem(Tools.getLabel(messages.getString("guiMenuShowMainWindow")));
  restoreItem.addActionListener(rmbListener);
  popup.add(restoreItem);
  // Exit:
  MenuItem exitItem = new MenuItem(Tools.getLabel(messages.getString("guiMenuQuit")));
  exitItem.addActionListener(rmbListener);
  popup.add(exitItem);
  return popup;
}
 
開發者ID:languagetool-org,項目名稱:languagetool,代碼行數:24,代碼來源:Main.java

示例3: initViewMenu

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

示例4: moveToTray

import java.awt.CheckboxMenuItem; //導入方法依賴的package包/類
private void moveToTray(final Settings settings, final Application application) {


		final PopupMenu popup = new PopupMenu();

		// Create a pop-up menu components
		final MenuItem syncItem = new MenuItem(UserMessage.get().MENU_ITEM_SYNCHRONIZE());
		final CheckboxMenuItem schedulerItem = new CheckboxMenuItem(UserMessage.get().MENU_ITEM_SCHEDULER_ACTIVE());
		final MenuItem logItem = new MenuItem(UserMessage.get().MENU_ITEM_SHOW_LOG());
		final MenuItem aboutItem = new MenuItem(UserMessage.get().MENU_ITEM_ABOUT());
		final MenuItem exitItem = new MenuItem(UserMessage.get().MENU_ITEM_EXIT());

		// let the tray icon listen to sync events for state change
		application.addObserver(getTrayIcon());

		//Add components to pop-up menu
		popup.add(syncItem);
		popup.add(schedulerItem);
		popup.add(logItem);
		popup.add(aboutItem);
		popup.addSeparator();
		popup.add(exitItem);
		getTrayIcon().setPopupMenu(popup);

		application.reloadSettings();

		final JFrame logWindow = createLogWindow(Level.toLevel(settings.getPopupThresholdLevel(), Level.INFO));
		final JFrame aboutWindow = createAboutWindow();

		final ActionListener syncActionListener = createSyncActionListener(application.getScheduler());
		syncItem.addActionListener(syncActionListener);
		// sync also on double click
		getTrayIcon().addActionListener(syncActionListener);
		getTrayIcon().addMouseListener(createLogMouseListener(logWindow));

		schedulerItem.addItemListener(createSchedulerItemListener(settings, application));
		logItem.addActionListener(createLogActionListener(logWindow));
		aboutItem.addActionListener(createAboutActionListener(aboutWindow));
		exitItem.addActionListener(createExitActionListener(logWindow, aboutWindow));

		schedulerItem.setState(settings.isSchedulerStarted());
		toggleScheduler(settings.isSchedulerStarted(), settings, application);

	}
 
開發者ID:fjakop,項目名稱:ngcalsync,代碼行數:45,代碼來源:TrayStarter.java


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