本文整理汇总了Java中javafx.scene.control.CheckMenuItem.setSelected方法的典型用法代码示例。如果您正苦于以下问题:Java CheckMenuItem.setSelected方法的具体用法?Java CheckMenuItem.setSelected怎么用?Java CheckMenuItem.setSelected使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.control.CheckMenuItem
的用法示例。
在下文中一共展示了CheckMenuItem.setSelected方法的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);
}
示例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;
}
示例3: hadleDauerSelect
import javafx.scene.control.CheckMenuItem; //导入方法依赖的package包/类
/**
* Hacky solution for the quality selector, which makes it sure only one quality can be selectet at
* a time. The selected quality is stored as a String in the global variable qualitySelected for a still
* unsure purpose
* @param e
*/
@FXML
private void hadleDauerSelect(ActionEvent e){
Object source = e.getSource();
dselectedMenuItem = (CheckMenuItem) source;
high.setSelected(false);
medium.setSelected(false);
low.setSelected(false);
dselectedMenuItem.setSelected(true);
dauerSelected = dselectedMenuItem.getId();
switch (dauerSelected.toLowerCase().charAt(0)){
case 'l': beleuchtungsDauer = 0;
System.out.println("hello777");
break;
case 'm': beleuchtungsDauer = 1;
System.out.println("hello123");
break;
case 'h': beleuchtungsDauer = 2;
break;
}
System.out.println(beleuchtungsDauer);
dauerChoose.setText("Beleuchtung: "+ dselectedMenuItem.getText());
//System.out.println(qualitySelected + " Qualität Selektiert");
// Btw \u00E4 das ist ein kleines ä in unicode http://www.bennyn.de/programmierung/java/umlaute-und-sonderzeichen-in-java.html
}
示例4: handleStartWithWindowsClick
import javafx.scene.control.CheckMenuItem; //导入方法依赖的package包/类
public EventHandler<ActionEvent> handleStartWithWindowsClick(boolean allUsers, CheckMenuItem otherItem)
{
return ae ->
{
boolean add = ((CheckMenuItem) ae.getSource()).isSelected();
try
{
StartWithWindowsRegistryUtils.setRegistryToStartWithWindows(add, allUsers);
}
catch (IOException ioe)
{
logger.log(Level.SEVERE, "Unable to modify the registry for the \"start with Windows\" setting", ioe);
new Alert(AlertType.ERROR, "Unable to modify the registry for the \"start with Windows\" setting").showAndWait();
return;
}
otherItem.setSelected(false); //if one is selected, the other one has to be unselected. if the click is to de-select, the other one was already unselected as well anyway.
Alert success = new Alert(AlertType.INFORMATION, Main.appTitle + (add ? " is now set to " : " will not ") + "start with Windows for " + (allUsers ? "all users" : "this user"));
success.setTitle("Start with Windows");
success.setHeaderText("Setting changed");
success.showAndWait();
};
}
示例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;
}
示例6: 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;
}
示例7: hadleQualitySelect
import javafx.scene.control.CheckMenuItem; //导入方法依赖的package包/类
/**
* Hacky solution for the quality selector, which makes it sure only one quality can be selectet at
* a time. The selected quality is stored as a String in the global variable qualitySelected for a still
* unsure purpose
* @param e
*/
@FXML
private void hadleQualitySelect(ActionEvent e){
Object source = e.getSource();
selectedMenuItem = (CheckMenuItem) source;
abnormalHigh.setSelected(false);
ultraHigh.setSelected(false);
veryHigh.setSelected(false);
// high.setSelected(false);
// medium.setSelected(false);
// low.setSelected(false);
selectedMenuItem.setSelected(true);
qualitySelected = selectedMenuItem.getId();
switch (qualitySelected.toLowerCase().charAt(0)){
case 'l': bilderZahl = 16;
System.out.println("hello777");
break;
case 'm': bilderZahl = 32;
System.out.println("hello123");
break;
case 'h': bilderZahl = 64;
break;
case 'v': bilderZahl = 128;
break;
case 'u': bilderZahl = 256;
break;
case 'a': bilderZahl = 512;
break;
}
System.out.println(bilderZahl);
qualityChoose.setText("Qualit\u00E4t: "+ selectedMenuItem.getText());
//System.out.println(qualitySelected + " Qualität Selektiert");
System.out.println(selectedMenuItem.getText() + qualitySelected );
// Btw \u00E4 das ist ein kleines ä in unicode http://www.bennyn.de/programmierung/java/umlaute-und-sonderzeichen-in-java.html
}
示例8: createMenuItem
import javafx.scene.control.CheckMenuItem; //导入方法依赖的package包/类
private CheckMenuItem createMenuItem(String title, String toolName){
CheckMenuItem cmi = new CheckMenuItem(title);
cmi.setSelected(false);
cmi.selectedProperty().addListener(new ChangeListener<Boolean>() {
public void changed(ObservableValue ov, Boolean old_val, Boolean new_val) {
if (new_val) {
long SLEEP_TIME = 100;
cmi.setSelected(true);
Platform.runLater(() -> {
//mainScene.openSwingTab();
});
try {
TimeUnit.MILLISECONDS.sleep(SLEEP_TIME);
} catch (InterruptedException e) {
e.printStackTrace();
}
SwingUtilities.invokeLater(() -> {
desktop.openToolWindow(toolName);
//desktop.repaint();
});
//desktop.repaint();
} else {
cmi.setSelected(false);
SwingUtilities.invokeLater(() -> {
desktop.closeToolWindow(toolName);
//desktop.repaint();
});
}
}
});
return cmi;
}
示例9: checkCorrectMenu
import javafx.scene.control.CheckMenuItem; //导入方法依赖的package包/类
protected void checkCorrectMenu(CheckMenuItem currentItem, String menuName){
for (MenuItem item: currentMenu.getItems()){
((CheckMenuItem)item).setSelected(false);
}
currentItem.setSelected(true);
linkMovement(menuName);
}
示例10: 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);
}
}
示例11: 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);
}
示例12: createMenuItem
import javafx.scene.control.CheckMenuItem; //导入方法依赖的package包/类
private static CheckMenuItem createMenuItem(String title) {
CheckMenuItem cmi = new CheckMenuItem(title);
cmi.setSelected(true);
return cmi;
}
示例13: 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);
}
示例14: 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);
}
示例15: 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);
}