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


Java RadioMenuItem類代碼示例

本文整理匯總了Java中javafx.scene.control.RadioMenuItem的典型用法代碼示例。如果您正苦於以下問題:Java RadioMenuItem類的具體用法?Java RadioMenuItem怎麽用?Java RadioMenuItem使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: marathon_select

import javafx.scene.control.RadioMenuItem; //導入依賴的package包/類
@Override public boolean marathon_select(String value) {
    MenuBar menuBar = (MenuBar) node;
    ObservableList<Menu> menus = menuBar.getMenus();
    String[] items = value.split("\\>\\>");
    Menu parentMenu = getParentMenu(menus, items[0]);
    List<MenuItem> menuItems = new ArrayList<>();
    for (int i = 1; i < items.length; i++) {
        getChidernMenuItem(parentMenu, items[i], menuItems);
    }
    parentMenu.fire();
    menuItems.stream().forEach((menu) -> {
        if (menu instanceof CheckMenuItem) {
            CheckMenuItem checkMenuItem = (CheckMenuItem) menu;
            checkMenuItem.setSelected(!checkMenuItem.isSelected());
        } else if (menu instanceof RadioMenuItem) {
            RadioMenuItem radioMenuItem = (RadioMenuItem) menu;
            radioMenuItem.setSelected(!isSelected());
        }
        menu.fire();
    });
    return true;
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:23,代碼來源:JavaFXMenuBarElement.java

示例2: marathon_select

import javafx.scene.control.RadioMenuItem; //導入依賴的package包/類
@Override public boolean marathon_select(String value) {
    String[] items = value.split("\\>\\>");
    ObservableList<MenuItem> children = contextMenu.getItems();
    List<MenuItem> menuItems = new ArrayList<>();
    for (String item : items) {
        getChidernMenuItem(children, item, menuItems);
    }
    menuItems.stream().forEach((menu) -> {
        if (menu instanceof CheckMenuItem) {
            CheckMenuItem checkMenuItem = (CheckMenuItem) menu;
            checkMenuItem.setSelected(!checkMenuItem.isSelected());
        } else if (menu instanceof RadioMenuItem) {
            RadioMenuItem radioMenuItem = (RadioMenuItem) menu;
            radioMenuItem.setSelected(!isSelected());
        }
        menu.fire();
    });
    contextMenu.hide();
    return true;
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:21,代碼來源:JavaFXContextMenuElement.java

示例3: updateMenuItems

import javafx.scene.control.RadioMenuItem; //導入依賴的package包/類
private void updateMenuItems() {
    ToggleGroup group = new ToggleGroup();
    List<MenuItem> items = new ArrayList<>();
    for (Calendar calendar : getSkinnable().getCalendars()) {
        RadioMenuItem item = new RadioMenuItem(calendar.getName());
        Rectangle icon = new Rectangle(10, 10);
        icon.setArcHeight(2);
        icon.setArcWidth(2);
        icon.getStyleClass().add(calendar.getStyle() + "-icon"); //$NON-NLS-1$
        item.setGraphic(icon);
        item.setDisable(calendar.isReadOnly());
        item.setOnAction(evt -> getSkinnable().setCalendar(calendar));
        group.getToggles().add(item);
        items.add(item);
        if (calendar.equals(getSkinnable().getCalendar())) {
            item.setSelected(true);
        }
    }

    button.getItems().setAll(items);
}
 
開發者ID:dlemmermann,項目名稱:CalendarFX,代碼行數:22,代碼來源:CalendarSelectorSkin.java

示例4: initMenu

import javafx.scene.control.RadioMenuItem; //導入依賴的package包/類
private void initMenu() {
  recentSupport = new RecentFileMenuSupport(openRecentMenu) {
    @Override
    public List<String> load() {
      return Arrays.asList(Config.getProperty(ConfigKey.RECENT_LOCATIONS, "").split(","));
    }

    @Override
    public void save(List<String> s) {
      Config.setProperty(ConfigKey.RECENT_LOCATIONS, String.join(", ", s));
    }
  };
  recentSupport.setOnAction(this::openFile);

  ToggleGroup group = new ToggleGroup();
  for (SkinStyle style : Context.SKIN.getSkinList()) {
    RadioMenuItem item = new RadioMenuItem(style.getName());
    item.setToggleGroup(group);
    item.setOnAction(e -> Context.SKIN.changeSkin(style));
    if (Context.SKIN.currentSkin() == style) {
      item.setSelected(true);
    }
    skinMenu.getItems().add(item);
  }
}
 
開發者ID:XDean,項目名稱:CSS-Editor-FX,代碼行數:26,代碼來源:MainFrameController.java

示例5: chooseBackground

import javafx.scene.control.RadioMenuItem; //導入依賴的package包/類
private void chooseBackground(int background, ActionEvent event) {
	if (background == IMAGE_1) {
		ArmaDialogCreator.getCanvasView().setCanvasBackgroundToImage(ADCImagePaths.BG_1);
	} else if (background == IMAGE_2) {
		ArmaDialogCreator.getCanvasView().setCanvasBackgroundToImage(ADCImagePaths.BG_2);
	} else if (background == IMAGE_3) {
		ArmaDialogCreator.getCanvasView().setCanvasBackgroundToImage(ADCImagePaths.BG_3);
	} else if (background == NO_IMAGE) {
		ArmaDialogCreator.getCanvasView().setCanvasBackgroundToImage(null);
	} else if (background == IMAGE_CUSTOM) {
		FileChooser c = new FileChooser();
		FileChooser.ExtensionFilter filter = new FileChooser.ExtensionFilter("Images", "*.png", "*.gif", "*.jpg", "*.mpo");
		c.getExtensionFilters().add(filter);
		c.setSelectedExtensionFilter(filter);
		c.setTitle(Lang.ApplicationBundle().getString("Misc.file_chooser_background_img_title"));
		File chosen = c.showOpenDialog(ArmaDialogCreator.getPrimaryStage());
		if (chosen != null) {
			ArmaDialogCreator.getCanvasView().setCanvasBackgroundToImage(chosen.toURI().toString());
		} else {
			RadioMenuItem target = (RadioMenuItem) event.getTarget();
			target.getToggleGroup().selectToggle(target.getToggleGroup().getToggles().get(lastBackground));
		}
	}
}
 
開發者ID:kayler-renslow,項目名稱:arma-dialog-creator,代碼行數:25,代碼來源:ViewBackgroundAction.java

示例6: InvisibleItemsMenu

import javafx.scene.control.RadioMenuItem; //導入依賴的package包/類
public InvisibleItemsMenu() {
    super(INVISIBLE_ID);
    setId(INVISIBLE_ID);

    getItems().addAll(
            new MenuItem("Menu Item", new Rectangle(10, 10)),
            new MenuItem("Invisible Menu Item", new Rectangle(10, 10)),
            new CheckMenuItem("Check Item", new Rectangle(10, 10)),
            new CheckMenuItem("Invisible Check Item", new Rectangle(10, 10)),
            new RadioMenuItem("Radio Item", new Rectangle(10, 10)),
            new RadioMenuItem("Invisible Radio Item", new Rectangle(10, 10)),
            new CustomMenuItem(new Label("Custom Item")),
            new CustomMenuItem(new Label("Invisible Custom Item")));

    setEventHandlers();
}
 
開發者ID:teamfx,項目名稱:openjfx-8u-dev-tests,代碼行數:17,代碼來源:MenuItemApp.java

示例7: radioGroupTest

import javafx.scene.control.RadioMenuItem; //導入依賴的package包/類
@Smoke
@Test(timeout = 300000)
public void radioGroupTest() throws InterruptedException {
    Wrap<? extends Menu> menu = menuBarAsParent.lookup(new MenuByText(MenuItemApp.RADIO_ID)).wrap();
    Parent<MenuItem> menu_as_parent = menu.as(Parent.class, MenuItem.class);
    for (int i = 0; i < menu_as_parent.lookup().size(); i++) {
        Wrap<? extends MenuItem> item_wrap = menu_as_parent.lookup().wrap(i);
        MenuItem item = item_wrap.getControl();
        expand(menu, true);
        item_wrap.mouse().click();
        for (int j = 0; j < menu_as_parent.lookup().size(); j++) {
            Wrap<? extends MenuItem> another_item_wrap = menu_as_parent.lookup().wrap(i);
            final MenuItem another_item = another_item_wrap.getControl();
            expand(menu, true);
            item_wrap.mouse().click();
            if (!another_item.equals(item)) {
                assertFalse(new GetAction<Boolean>() {
                    @Override
                    public void run(Object... parameters) {
                        setResult(((RadioMenuItem) another_item).isSelected());
                    }
                }.dispatch(Root.ROOT.getEnvironment()));
            }
        }
    }
}
 
開發者ID:teamfx,項目名稱:openjfx-8u-dev-tests,代碼行數:27,代碼來源:MenuItemTest.java

示例8: wrap

import javafx.scene.control.RadioMenuItem; //導入依賴的package包/類
@Override
public <T> Wrap<? extends T> wrap(Class<T> controlClass, T control) {
    if (MenuItem.class.isInstance(control)) {
        if (Menu.class.isInstance(control)) {
            return (Wrap<? extends T>)
                    new MenuWrap<>(wrap.getEnvironment(), Menu.class.cast(control));
        } else if (RadioMenuItem.class.isInstance(control)) {
            return (Wrap<? extends T>)
                    new RadioMenuItemWrap<>(wrap.getEnvironment(), RadioMenuItem.class.cast(control));
        } else if (CheckMenuItem.class.isInstance(control)) {
            return (Wrap<? extends T>)
                    new CheckMenuItemWrap<>(wrap.getEnvironment(), CheckMenuItem.class.cast(control));
        } else {
            return (Wrap<? extends T>) new MenuItemWrap(wrap.getEnvironment(), MenuItem.class.cast(control));
        }
    }
    throw new JemmyException("Unexpected control class is used: " + controlClass);
}
 
開發者ID:teamfx,項目名稱:openjfx-8u-dev-tests,代碼行數:19,代碼來源:MenuItemParent.java

示例9: getCurrentClockSpeed

import javafx.scene.control.RadioMenuItem; //導入依賴的package包/類
private int getCurrentClockSpeed() {
	for(MenuItem menuItem : frequenciesMenu.getItems()) {
		RadioMenuItem clockItem = (RadioMenuItem)menuItem;
		if(clockItem.isSelected()) {
			String text = clockItem.getText();
			int space = text.indexOf(' ');
			if(space == -1) {
				throw new IllegalStateException("What did you do...");
			}
			
			return Integer.parseInt(text.substring(0, space));
		}
	}
	
	throw new IllegalStateException("This can't happen lol");
}
 
開發者ID:ra4king,項目名稱:CircuitSim,代碼行數:17,代碼來源:CircuitSim.java

示例10: initializeZoomOptions

import javafx.scene.control.RadioMenuItem; //導入依賴的package包/類
/**
 * Initializes the list of zoom options.
 */
private void initializeZoomOptions() {

    final ToggleGroup toggleGroup = new ToggleGroup();

    for (int i = 1; i <= 5; i++) {

        final RadioMenuItem zoomOption = new RadioMenuItem();
        final double zoomFactor = i;

        zoomOption.setText(i + "00%");
        zoomOption.setOnAction(event -> setZoomFactor(zoomFactor));

        toggleGroup.getToggles().add(zoomOption);
        zoomOptions.getItems().add(zoomOption);

        if (i == 1) {
            zoomOption.setSelected(true);
        }
    }
}
 
開發者ID:Heverton,項目名稱:grapheditor,代碼行數:24,代碼來源:GraphEditorDemoController.java

示例11: initialize

import javafx.scene.control.RadioMenuItem; //導入依賴的package包/類
@Override
public void initialize(URL location, ResourceBundle resources) {
    closeJarButton.setDisable(Main.getLoadedJar() == null);
    loadMappingsButton.setDisable(Main.getLoadedJar() == null);
    mergeMappingsButton.setDisable(Main.getLoadedJar() == null);
    saveMappingsButton.setDisable(Main.getLoadedJar() == null);
    saveMappingsAsButton.setDisable(Main.getLoadedJar() == null);
    resetMappingsButton.setDisable(Main.getLoadedJar() == null);

    final String langRadioPrefix = "langRadio-";
    for (Toggle toggle : languageGroup.getToggles()) {
        if (((RadioMenuItem) toggle).getId().equals(langRadioPrefix + Main.getCurrentLocale())) {
            toggle.setSelected(true);
            break;
        }
    }

    setAccelerators();

    this.initTreeViews();

    RESTART_ALERT.setTitle(Main.getResourceBundle().getString("dialog.restart.title"));
    RESTART_ALERT.setHeaderText(null);
    RESTART_ALERT.setContentText(Main.getResourceBundle().getString("dialog.restart.content"));
}
 
開發者ID:LapisBlue,項目名稱:Nocturne,代碼行數:26,代碼來源:MainController.java

示例12: onPriorityAction

import javafx.scene.control.RadioMenuItem; //導入依賴的package包/類
private void onPriorityAction(final RadioMenuItem priorityMenuItem) {
	final CheckBoxTreeItem<TorrentFileEntry> treeItem = (CheckBoxTreeItem<TorrentFileEntry>)getTreeItem();
	final FilePriority newPriorityValue = FilePriority.values()[Integer.parseInt(priorityMenuItem.getId())];
	if(treeItem.getValue().getPriority() != newPriorityValue) { 
		if(treeItem.isIndeterminate()) {
			treeItem.setSelected(true);
			treeItem.getValue().selectedProperty().set(newPriorityValue != FilePriority.SKIP);
		}
		else {
			treeItem.setSelected(newPriorityValue != FilePriority.SKIP);
		}
							
		if(!treeItem.isLeaf()) {
			fileTreeViewer.onUpdateChildrenPriority(treeItem, newPriorityValue);
		}
		treeItem.getValue().priorityProperty().set(newPriorityValue);
		fileTreeViewer.onUpdateParentPriority(treeItem.getParent());
		fileTreeViewer.selectItem(treeItem);
	}
}
 
開發者ID:veroslav,項目名稱:jfx-torrent,代碼行數:21,代碼來源:TorrentContentTreeRow.java

示例13: buildRemoveButtonContextMenu

import javafx.scene.control.RadioMenuItem; //導入依賴的package包/類
private ContextMenu buildRemoveButtonContextMenu() {
    final ContextMenu removeOptionsMenu = new ContextMenu();

    final List<RadioMenuItem> removeOptionMenuItems = Arrays.asList(new RadioMenuItem[]{
            new RadioMenuItem("Remove"), new RadioMenuItem("Remove and delete .torrent"),
            new RadioMenuItem("Remove and delete .torrent + Data"),
            new RadioMenuItem("Remove and delete Data")});

    final ToggleGroup removeOptionsToggle = new ToggleGroup();
    removeOptionMenuItems.forEach(i -> i.setToggleGroup(removeOptionsToggle));
    removeOptionMenuItems.get(0).setSelected(true);

    removeOptionsMenu.getItems().addAll(removeOptionMenuItems);
    removeOptionsMenu.getItems().addAll(new SeparatorMenuItem(),
            new CheckMenuItem("Move to trash if possible"));

    return removeOptionsMenu;
}
 
開發者ID:veroslav,項目名稱:jfx-torrent,代碼行數:19,代碼來源:ApplicationWindow.java

示例14: check

import javafx.scene.control.RadioMenuItem; //導入依賴的package包/類
public static CheckItemBuilt check(String name, boolean checked) {
    RadioMenuItem item = new RadioMenuItem() {
        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;

            MenuItem i = (MenuItem) o;

            return !(getText() != null ? !getText().equals(i.getText()) : i.getText() != null);

        }

        @Override
        public int hashCode() {
            return getText() != null ? getText().hashCode() : 0;
        }
    };
    item.setMnemonicParsing(false);
    item.setSelected(checked);
    item.setText(name);
    final CheckItemBuilt checkItemBuilt = new CheckItemBuilt(item);
    return checkItemBuilt;
}
 
開發者ID:asciidocfx,項目名稱:AsciidocFX,代碼行數:25,代碼來源:CheckItemBuilt.java

示例15: didClickPlayerMenuItem

import javafx.scene.control.RadioMenuItem; //導入依賴的package包/類
public void didClickPlayerMenuItem(ActionEvent e) {
	ColorTypes type = (ColorTypes)((RadioMenuItem)e.getSource()).getUserData();

	colors.setPlayerColor(new StoneColor(type));
	updateColorMenu();
	draw();
	UserDefaults.sharedDefaults().setKey(UserDefaults.STONE_COLORS_KEY, colors);
}
 
開發者ID:lukasbischof,項目名稱:Orsum-occulendi,代碼行數:9,代碼來源:GameController.java


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