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


Java CheckMenuItem.setOnAction方法代码示例

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


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

示例1: windowsMenuHelper

import javafx.scene.control.CheckMenuItem; //导入方法依赖的package包/类
/**
 * Dynamically generates the windows menu items
 *
 * @param windowsMenu
 *            The windows menu to add the items to
 */
private void windowsMenuHelper(Menu windowsMenu) {
	windowsMenu.getItems().clear();
	for (WindowEnum wenum : WindowEnum.values()) {
		if (wenum.showInWindowsMenu()) {
			CheckMenuItem item = new CheckMenuItem(wenum.toString());
			item.setSelected(wm.getWorkspace().windowIsOpen(wenum));
			item.setOnAction(e -> {
				InternalWindow window = wm.getWorkspace().findInternalWindow(wenum);
				if (window == null)
					wm.getWorkspace().openInternalWindow(wenum);
				else
					window.close();
			});
			windowsMenu.getItems().add(item);
		}
	}

	MenuItem delWindows = new MenuItem("Close All");
	delWindows.setOnAction(e -> wm.getWorkspace().closeAll());
	windowsMenu.getItems().addAll(new SeparatorMenuItem(), delWindows);
}
 
开发者ID:mbway,项目名称:Simulizer,代码行数:28,代码来源:MainMenuBar.java

示例2: createSearchSubmenu

import javafx.scene.control.CheckMenuItem; //导入方法依赖的package包/类
/**
 * Function to create the search submenu for the top.
 *
 * @param filePersistentStorage The file storage to retrieve the state.
 * @return                      The search submenu options.
 */
private Menu createSearchSubmenu(FilePersistentStorage filePersistentStorage) {
    Menu searchSubMenu = new Menu(SEARCH_HEADER);
    CheckMenuItem showFilesInFolderHits = new CheckMenuItem(SHOW_FILES_IN_FOLDER_HITS_HEADER);
    showFilesInFolderHits.setSelected(filePersistentStorage.getShowFilesInFolderHit());

    showFilesInFolderHits.setOnAction(event -> {
        if (showFilesInFolderHits.isSelected()) {
            m_model.getM_menuOptions().setShowFilesInFolderSearchHit(true);
        } else {
            m_model.getM_menuOptions().setShowFilesInFolderSearchHit(false);
        }
        m_model.notifySearchObservers();
    });

    searchSubMenu.getItems().add(showFilesInFolderHits);

    return searchSubMenu;
}
 
开发者ID:ijh165,项目名称:Gamma-Music-Manager,代码行数:25,代码来源:MenuUI.java

示例3: refreshTaskMenu

import javafx.scene.control.CheckMenuItem; //导入方法依赖的package包/类
private void refreshTaskMenu(ObservableList<MenuItem> menuItemList,
                             IResource currentRowResource,
                             ObservableList<ITask> taskList) {
    menuItemList.clear();
    for (ITask task : taskList) {
        CheckMenuItem checkMenuItem = new CheckMenuItem(task.getName());
        task.getResourceList()
                .stream()
                .filter(resource -> resource.equals(currentRowResource) && !checkMenuItem.isSelected())
                .forEach(resource -> checkMenuItem.setSelected(true));
        checkMenuItem.setOnAction(event -> {
            if (checkMenuItem.isSelected()) {
                controller.getCommandExecutor().execute(new AddResourceToTaskCommand(task, currentRowResource));
            } else {
                controller.getCommandExecutor().execute(new RemoveResourceFromTaskCommand(task, currentRowResource));
            }
        });
        menuItemList.add(checkMenuItem);
    }
}
 
开发者ID:khasang,项目名称:Cachoeira,代码行数:21,代码来源:ResourceContextMenu.java

示例4: refreshResourceMenu

import javafx.scene.control.CheckMenuItem; //导入方法依赖的package包/类
private void refreshResourceMenu(ObservableList<MenuItem> menuItemList,
                                 ITask task,
                                 ObservableList<IResource> resourceList) {
    menuItemList.clear();
    for (IResource resource : resourceList) {                                                                  //берем список всех ресурсов
        CheckMenuItem checkMenuItem = new CheckMenuItem(resource.getName());                                //создаем элемент меню для каждого ресурса
        task.getResourceList()
                .stream()
                .filter(resourceOfTask -> resource.equals(resourceOfTask) && !checkMenuItem.isSelected())
                .forEach(resourceOfTask -> checkMenuItem.setSelected(true));
        checkMenuItem.setOnAction(event -> {
            if (checkMenuItem.isSelected()) {
                controller.getCommandExecutor().execute(new AddResourceToTaskCommand(task, resource));
            } else {
                controller.getCommandExecutor().execute(new RemoveResourceFromTaskCommand(task, resource));
            }
        });
        menuItemList.add(checkMenuItem);
    }
}
 
开发者ID:khasang,项目名称:Cachoeira,代码行数:21,代码来源:TaskContextMenu.java

示例5: newCheckMenuItem

import javafx.scene.control.CheckMenuItem; //导入方法依赖的package包/类
public static CheckMenuItem newCheckMenuItem(final String text, final EventHandler<ActionEvent> eventHandler, final boolean isSelected) {
	final
	CheckMenuItem checkMenuItem = new CheckMenuItem(text);
	checkMenuItem.setOnAction(eventHandler);
	checkMenuItem.setSelected(isSelected);
	
	return checkMenuItem;
}
 
开发者ID:macroing,项目名称:Dayflower-Path-Tracer,代码行数:9,代码来源:JavaFX.java

示例6: createControl

import javafx.scene.control.CheckMenuItem; //导入方法依赖的package包/类
@Override
protected Node createControl() {
    entryView = createEntryView(entry);
    entryView.getStylesheets().add(HelloDayEntryView.class.getResource("entry.css").toExternalForm());
    control = entryView;

    ContextMenu menu = new ContextMenu();

    // red border
    CheckMenuItem redBorder = new CheckMenuItem("Red Border");
    menu.getItems().add(redBorder);
    redBorder.setOnAction(evt -> {
        if (redBorder.isSelected()) {
            entry.getStyleClass().add(RED_BORDER_STYLE);
        } else {
            entry.getStyleClass().remove(RED_BORDER_STYLE);
        }
    });

    // red background
    CheckMenuItem redBackground = new CheckMenuItem("Orange Background");
    menu.getItems().add(redBackground);
    redBackground.setOnAction(evt -> {
        if (redBackground.isSelected()) {
            entry.getStyleClass().add(ORANGE_BACKGROUND_STYLE);
        } else {
            entry.getStyleClass().remove(ORANGE_BACKGROUND_STYLE);
        }
    });

    entryView.setContextMenu(menu);

    return entryView;
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:35,代码来源:HelloEntryViewBase.java

示例7: getMinimodeMenu

import javafx.scene.control.CheckMenuItem; //导入方法依赖的package包/类
/**
   * Get the minimode Menu
*
   * @return The minimode menu
   */
  private Menu getMinimodeMenu() {
      Menu minimodeMenu = new Menu(MINI_MODE);
      m_minimodeMenuItem = new CheckMenuItem(MINI_MODE + "!");
      m_minimodeMenuItem.setSelected(m_miniCheck);
      m_minimodeMenuItem.setOnAction(event -> {
          System.out.println("Clicked minimode menu");
          fireMiniMode();
      });
      minimodeMenu.getItems().addAll(m_minimodeMenuItem);
      return minimodeMenu;
  }
 
开发者ID:ijh165,项目名称:Gamma-Music-Manager,代码行数:17,代码来源:MenuUI.java

示例8: addKeyMenus

import javafx.scene.control.CheckMenuItem; //导入方法依赖的package包/类
private void addKeyMenus(String movementType, Menu current, Stage keyStage){
	for (KeyCode key: KeyCode.values()){
		if (key.isArrowKey()||key.isLetterKey()){
			CheckMenuItem currentMenuItem=new CheckMenuItem(key.getName());
			current.getItems().add(currentMenuItem);
			currentMenuItem.setOnAction(e->linkKeys(movementType, key, keyStage));
		}
	}
}
 
开发者ID:ngbalk,项目名称:VOOGASalad,代码行数:10,代码来源:SpriteMovement.java

示例9: addSemanticsMenuItems

import javafx.scene.control.CheckMenuItem; //导入方法依赖的package包/类
private void addSemanticsMenuItems(Menu menu, TreeItem<Resource> treeItem)
{
    GuideReference.Semantics[] semantics = GuideReference.Semantics.values();
    Resource resource = treeItem.getValue();
    Guide guide = book.getGuide();
    for (GuideReference.Semantics semantic : semantics)
    {
        CheckMenuItem item = new CheckMenuItem(semantic.getDescription());
        List<GuideReference> typeReferences = guide.getGuideReferencesByType(semantic);
        for (GuideReference typeReference : typeReferences)
        {
            if (typeReference.getResource().equals(resource))
            {
                item.setSelected(true);
            }
        }
        item.setUserData(treeItem);
        item.setOnAction(event -> {
            if (item.isSelected())
            {
                addSemanticsToXHTMLFile(treeItem, semantic);
                book.setBookIsChanged(true);
            }
            else
            {
                removeSemanticsFromXHTMLFile(treeItem, semantic);
                book.setBookIsChanged(true);
            }
        });
        menu.getItems().add(item);
    }

}
 
开发者ID:finanzer,项目名称:epubfx,代码行数:34,代码来源:BookBrowserManager.java

示例10: addImageSemantikMenuItems

import javafx.scene.control.CheckMenuItem; //导入方法依赖的package包/类
private void addImageSemantikMenuItems(Menu menu, TreeItem<Resource> treeItem)
{
    ImageResource resource = (ImageResource)treeItem.getValue();
    CheckMenuItem item = new CheckMenuItem("Deckblatt-Bild");
    if (resource.coverProperty().getValue())
    {
        item.setSelected(true);
    }
    else
    {
        item.setSelected(false);
    }
    item.setUserData(treeItem);
    item.setOnAction(event -> {
        if (item.isSelected())
        {
            resource.coverProperty().setValue(true);
            book.setBookIsChanged(true);
        }
        else
        {
            resource.coverProperty().setValue(false);
            book.setBookIsChanged(true);
        }
    });
    menu.getItems().add(item);
}
 
开发者ID:finanzer,项目名称:epubfx,代码行数:28,代码来源:BookBrowserManager.java

示例11: editMenuHelper

import javafx.scene.control.CheckMenuItem; //导入方法依赖的package包/类
/**
 * Generates the edit menu
 */
private void editMenuHelper(Menu editMenu, boolean allowDisabling) {
	// NOTE: these are handled inside the editor code instead (see Editor::Editor())
	editMenu.getItems().clear();

	Editor e = (Editor) wm.getWorkspace().findInternalWindow(WindowEnum.EDITOR);

	MenuItem cut = new MenuItem("Cut");
	cut.setDisable(allowDisabling && (e == null || e.getMode() == Editor.Mode.EXECUTE_MODE));
	cut.setAccelerator(new KeyCodeCombination(KeyCode.X, KeyCombination.CONTROL_DOWN));
	cut.setOnAction((a) -> passToEditor(KeyCode.X));

	MenuItem copy = new MenuItem("Copy");
	copy.setDisable(allowDisabling && (e == null || e.getMode() == Editor.Mode.EXECUTE_MODE));
	copy.setAccelerator(new KeyCodeCombination(KeyCode.C, KeyCombination.CONTROL_DOWN));
	copy.setOnAction((a) -> passToEditor(KeyCode.C));

	MenuItem paste = new MenuItem("Paste");
	paste.setDisable(allowDisabling && (e == null || e.getMode() == Editor.Mode.EXECUTE_MODE));
	paste.setAccelerator(new KeyCodeCombination(KeyCode.V, KeyCombination.CONTROL_DOWN));
	paste.setOnAction((a) -> passToEditor(KeyCode.V));

	MenuItem find = new MenuItem("Find");
	find.setAccelerator(new KeyCodeCombination(KeyCode.F, KeyCombination.CONTROL_DOWN));
	find.setOnAction((a) -> passToEditor(KeyCode.F));

	MenuItem gotoL = new MenuItem("Go To Line");
	gotoL.setAccelerator(new KeyCodeCombination(KeyCode.G, KeyCombination.CONTROL_DOWN));
	gotoL.setOnAction((a) -> passToEditor(KeyCode.G));

	MenuItem insertBreakpoint = new MenuItem("Insert Breakpoint");
	insertBreakpoint.setDisable(allowDisabling && (e == null || e.getMode() == Editor.Mode.EXECUTE_MODE));
	insertBreakpoint.setAccelerator(new KeyCodeCombination(KeyCode.B, KeyCombination.CONTROL_DOWN));
	insertBreakpoint.setOnAction((a) -> passToEditor(KeyCode.B));

	MenuItem fontInc = new MenuItem("Increase Font Size");
	fontInc.setAccelerator(new KeyCodeCombination(KeyCode.PLUS, KeyCombination.CONTROL_DOWN));
	fontInc.setOnAction((a) -> passToEditor(KeyCode.PLUS));

	MenuItem fontDec = new MenuItem("Decrease Font Size");
	fontDec.setAccelerator(new KeyCodeCombination(KeyCode.MINUS, KeyCombination.CONTROL_DOWN));
	fontDec.setOnAction((a) -> passToEditor(KeyCode.MINUS));

	CheckMenuItem wordWrap = new CheckMenuItem("Toggle Word Wrap");
	wordWrap.setSelected(e != null && e.getWrap());
	wordWrap.setOnAction((a) -> {
		if (e != null)
			e.setWrap(!e.getWrap());
	});

	editMenu.getItems().addAll(cut, copy, paste, find, gotoL, insertBreakpoint, fontInc, fontDec, wordWrap);
}
 
开发者ID:mbway,项目名称:Simulizer,代码行数:55,代码来源:MainMenuBar.java

示例12: layoutMenu

import javafx.scene.control.CheckMenuItem; //导入方法依赖的package包/类
/**
 * A separate helper function to generate the layouts menu. Used to dynamically refresh the loaded layouts
 *
 * @param menu
 *            The layout menu
 */
private void layoutMenu(Menu menu) {
	menu.getItems().clear();

	for (Layout l : wm.getLayouts()) {
		String name = l.getName();
		MenuItem item = new MenuItem(name.endsWith(".json") ? name.substring(0, name.length() - 5) : name);
		item.setOnAction(e -> wm.getLayouts().setLayout(l));
		menu.getItems().add(item);
	}

	// | | | -- Save Layout
	MenuItem saveLayoutItem = new MenuItem("Save Current Layout");
	saveLayoutItem.setOnAction(e -> {
		File saveFile = UIUtils.saveFileSelector("Save layout", wm.getPrimaryStage(), "layouts", new ExtensionFilter("JSON Files *.json", "*.json"));
		if (saveFile != null) {
			if (!saveFile.getName().endsWith(".json"))
				saveFile = new File(saveFile.getAbsolutePath() + ".json");

			wm.getLayouts().saveLayout(saveFile);
			wm.getLayouts().reload(false);
			layoutMenu(menu);
		}
	});

	// | | | -- Refresh Layouts
	MenuItem reloadLayoutItem = new MenuItem("Refresh Layouts");
	reloadLayoutItem.setOnAction(e -> {
		wm.getLayouts().reload(false);
		layoutMenu(menu);
	});

	// | | | -- Toggle Fullscreen
	CheckMenuItem fullscreen = new CheckMenuItem("Fullscreen");
	wm.getPrimaryStage().setFullScreenExitKeyCombination(KeyCombination.NO_MATCH);
	fullscreen.setAccelerator(new KeyCodeCombination(KeyCode.F11));
	fullscreen.setSelected(wm.getPrimaryStage().isFullScreen());
	fullscreen.setOnAction(e -> {
		Stage wnd = wm.getPrimaryStage();
		wnd.setFullScreen(!wnd.isFullScreen());
	});

	menu.getItems().addAll(new SeparatorMenuItem(), saveLayoutItem, reloadLayoutItem, fullscreen);
}
 
开发者ID:mbway,项目名称:Simulizer,代码行数:50,代码来源:MainMenuBar.java

示例13: simControlsMenu

import javafx.scene.control.CheckMenuItem; //导入方法依赖的package包/类
/**
 * Dynamically generates the simulation menu items
 *
 * @param runMenu
 *            The simulation menu to add the items to
 * @param allowDisabling
 *            Force all the options to be enabled
 */
private void simControlsMenu(Menu runMenu, boolean allowDisabling) {
	runMenu.getItems().clear();

	final CPU cpu = wm.getCPU();

	MenuItem assembleAndRun = new MenuItem("Assemble and Run");
	assembleAndRun.setAccelerator(new KeyCodeCombination(KeyCode.F5));
	assembleAndRun.setDisable(allowDisabling && cpu.isRunning());
	assembleAndRun.setOnAction(e -> {
		if (!cpu.isRunning()) {
			wm.assembleAndRun();
		}
	});

	MenuItem pauseResume;
	if (!cpu.clockRunning()) {
		pauseResume = new MenuItem("Resume Simulation");
		pauseResume.setDisable(allowDisabling && (cpu.clockRunning() || !cpu.isRunning()));
	} else {
		pauseResume = new MenuItem("Pause Simulation");
		pauseResume.setDisable(allowDisabling && (!cpu.clockRunning() || !cpu.isRunning()));
	}
	pauseResume.setAccelerator(new KeyCodeCombination(KeyCode.F6));
	pauseResume.setOnAction(e -> {
		if (!cpu.clockRunning() && cpu.isRunning())
			cpu.resume();
		else if (cpu.clockRunning() && cpu.isRunning())
			cpu.pause();
	});

	MenuItem singleStep = new MenuItem("Single Step");
	singleStep.setAccelerator(new KeyCodeCombination(KeyCode.F7));
	singleStep.setDisable(allowDisabling && (cpu.clockRunning() || !cpu.isRunning()));
	singleStep.setOnAction(e -> {
		if (cpu.isPaused()) {
			cpu.resumeForOneCycle();
		}
	});

	MenuItem stop = new MenuItem("End Simulation");
	stop.setAccelerator(new KeyCodeCombination(KeyCode.F8));
	stop.setDisable(allowDisabling && !cpu.isRunning());
	stop.setOnAction(e -> {
		if (cpu.isRunning())
			wm.stopSimulation();
	});

	CheckMenuItem togglePipeline = new CheckMenuItem("Pipelined CPU?");
	togglePipeline.setDisable(cpu.isRunning());
	togglePipeline.setSelected(cpu.isPipelined());
	togglePipeline.setOnAction(e -> wm.newCPU(togglePipeline.isSelected()));

	CheckMenuItem toggleAnnotations = new CheckMenuItem("Annotations Enabled?");
	toggleAnnotations.setSelected(wm.getAnnotationManager().isEnabled());
	toggleAnnotations.setOnAction(e -> wm.getAnnotationManager().setEnabled(toggleAnnotations.isSelected()));

	MenuItem setClockSpeed = new MenuItem("Set Clock Speed");
	setClockSpeed.setOnAction(e -> {
		double currentRounded = Double.parseDouble(String.format("%.5f", cpu.getCycleFreq()));
		UIUtils.openDoubleInputDialog("Clock Speed", "Set Clock Speed:", "Cycles per second (Hz) (0 => ∞)", currentRounded, (val) -> {
			if (val >= 0) {
				cpu.setCycleFreq(val);
			} else {
				UIUtils.showErrorDialog("Value out of range", "The clock speed must be a positive value\n(can be fractional)");
			}
		});
	});

	runMenu.getItems().addAll(assembleAndRun, pauseResume, singleStep, stop, togglePipeline, toggleAnnotations, setClockSpeed);
}
 
开发者ID:mbway,项目名称:Simulizer,代码行数:79,代码来源:MainMenuBar.java

示例14: updateAppBar

import javafx.scene.control.CheckMenuItem; //导入方法依赖的package包/类
@Override
protected void updateAppBar(AppBar appBar) {
    appBar.setTitleText("Doodle Trace");

    //===================
    // Floating buttons
    //===================
    // Play animation button (Bottom Center)
    FloatingActionButton animateButton = new FloatingActionButton(
            MaterialDesignIcon.PLAY_ARROW.text, animAction);
    animateButton.setFloatingActionButtonHandler(
            FloatingActionButton.BOTTOM_CENTER);
    getLayers().add(animateButton.getLayer());

    // Clear Button (Botton Right)
    FloatingActionButton clearButton = new FloatingActionButton(
            MaterialDesignIcon.REFRESH.text, clearAction);
    clearButton.setFloatingActionButtonHandler(
            FloatingActionButton.BOTTOM_RIGHT);
    getLayers().add(clearButton.getLayer());

    //===================
    // Menu Items
    //===================
    // Checkbox Menu item to show or hide floating button controls
    CheckMenuItem showControlsMenuItem = new CheckMenuItem("Show/Hide Controls");
    showControlsMenuItem.setSelected(true);
    showControlsMenuItem.setOnAction(showAction -> {
        animateButton.setVisible(showControlsMenuItem.isSelected());
        clearButton.setVisible(showControlsMenuItem.isSelected());
    });

    // Menu item to animate
    MenuItem animateMenuItem = new MenuItem("Animate", MaterialDesignIcon.PLAY_ARROW.graphic());
    animateMenuItem.setOnAction(animAction);

    // Menu item to clear
    MenuItem clearMenuItem = new MenuItem("Clear", MaterialDesignIcon.REFRESH.graphic());
    clearMenuItem.setOnAction(clearAction);

    appBar.getMenuItems()
          .addAll(showControlsMenuItem, animateMenuItem, clearMenuItem);
}
 
开发者ID:gluonhq,项目名称:gluon-samples,代码行数:44,代码来源:DoodleTrace.java

示例15: addWindowMenuItem

import javafx.scene.control.CheckMenuItem; //导入方法依赖的package包/类
private void addWindowMenuItem(Stage stage, Menu menu) {
	CheckMenuItem item = new CheckMenuItem(stage.getTitle());
	item.setOnAction(event -> stage.toFront());
	createdMenuItems.put(stage, item);
	menu.getItems().add(item);
}
 
开发者ID:codecentric,项目名称:NSMenuFX,代码行数:7,代码来源:WindowMenuUpdateListener.java


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