本文整理汇总了Java中javafx.scene.control.RadioMenuItem.setToggleGroup方法的典型用法代码示例。如果您正苦于以下问题:Java RadioMenuItem.setToggleGroup方法的具体用法?Java RadioMenuItem.setToggleGroup怎么用?Java RadioMenuItem.setToggleGroup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.control.RadioMenuItem
的用法示例。
在下文中一共展示了RadioMenuItem.setToggleGroup方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
示例2: newRadioMenuItem
import javafx.scene.control.RadioMenuItem; //导入方法依赖的package包/类
public static RadioMenuItem newRadioMenuItem(final String text, final EventHandler<ActionEvent> eventHandler, final boolean isSelected, final ToggleGroup toggleGroup) {
final
RadioMenuItem radioMenuItem = new RadioMenuItem(text);
radioMenuItem.setOnAction(eventHandler);
radioMenuItem.setToggleGroup(toggleGroup);
radioMenuItem.setSelected(isSelected);
return radioMenuItem;
}
示例3: createMenuBar
import javafx.scene.control.RadioMenuItem; //导入方法依赖的package包/类
private MenuBar createMenuBar(GoogleAutoRefreshThread autoRefreshThread) {
MenuItem logoutItem = new MenuItem("Logout");
logoutItem.setOnAction(evt -> logout());
MenuItem exitItem = new MenuItem("Exit");
exitItem.setAccelerator(KeyCombination.keyCombination("shortcut+q"));
exitItem.setOnAction(evt -> Platform.exit());
Menu fileMenu = new Menu("File");
fileMenu.getItems().add(logoutItem);
fileMenu.getItems().add(exitItem);
MenuItem refreshItem = new MenuItem("Refresh");
refreshItem.setOnAction(evt -> autoRefreshThread.restart());
refreshItem.setAccelerator(KeyCombination.keyCombination("F5"));
ToggleGroup intervalGroup = new ToggleGroup();
Menu autoRefreshItem = new Menu("Auto Refresh");
for (GoogleAutoRefreshThread.RefreshInterval interval : GoogleAutoRefreshThread.RefreshInterval.values()) {
RadioMenuItem intervalItem = new RadioMenuItem(interval.getName());
intervalItem.setOnAction(evt -> autoRefreshThread.setDelay(interval.getTime()));
intervalItem.setToggleGroup(intervalGroup);
intervalItem.setSelected(interval.getTime() == autoRefreshThread.getDelay());
autoRefreshItem.getItems().add(intervalItem);
}
Menu viewMenu = new Menu("View");
viewMenu.getItems().addAll(refreshItem, autoRefreshItem);
MenuBar menuBar = new MenuBar();
menuBar.setUseSystemMenuBar(true);
menuBar.getMenus().add(fileMenu);
menuBar.getMenus().add(viewMenu);
return menuBar;
}
示例4: createFxMenuBar
import javafx.scene.control.RadioMenuItem; //导入方法依赖的package包/类
private MenuBar createFxMenuBar() {
MenuBar menuBar = new MenuBar();
Menu menu = new Menu("Language");
ToggleGroup group = new ToggleGroup();
LanguageVersion[] languageVersions = getSupportedLanguageVersions();
for (int i = 0; i < languageVersions.length; i++) {
LanguageVersion languageVersion = languageVersions[i];
// JRadioButtonMenuItem button = new JRadioButtonMenuItem(languageVersion.getShortName());
RadioMenuItem button = new RadioMenuItem(languageVersion.getShortName());
button.setToggleGroup(group);
languageVersionMenuItems[i] = button;
// group.add(button);
menu.getItems().add(button);
}
// languageVersionMenuItems[DEFAULT_LANGUAGE_VERSION_SELECTION_INDEX].setSelected(true);
languageVersionMenuItems[getDefaultLanguageVersionSelectionIndex()].setSelected(true);
menuBar.getMenus().add(menu);
Menu actionsMenu = new Menu("Actions");
MenuItem copyXMLItem = new MenuItem("Copy xml to clipboard");
copyXMLItem.setOnAction(e -> copyXmlToClipboard());
actionsMenu.getItems().add(copyXMLItem);
MenuItem createRuleXMLItem = new MenuItem("Create rule XML");
createRuleXMLItem.setOnAction(e -> createRuleXML());
actionsMenu.getItems().add(createRuleXMLItem);
menuBar.getMenus().add(actionsMenu);
return menuBar;
}
示例5: setMenuItem
import javafx.scene.control.RadioMenuItem; //导入方法依赖的package包/类
private RadioMenuItem setMenuItem (Menu menu, ToggleGroup toggleGroup, String itemName,
String selectedItemName, boolean disable)
{
RadioMenuItem item = new RadioMenuItem (itemName);
item.setToggleGroup (toggleGroup);
menu.getItems ().add (item);
if (itemName.equals (selectedItemName))
item.setSelected (true);
item.setDisable (disable);
item.setUserData (itemName);
item.setOnAction (e -> selectFont ());
return item;
}
示例6: RadioItemsMenu
import javafx.scene.control.RadioMenuItem; //导入方法依赖的package包/类
public RadioItemsMenu() {
super(RADIO_ID);
setId(RADIO_ID);
ToggleGroup group = new ToggleGroup();
for (int i = 0; i < 3; i++) {
RadioMenuItem item = new RadioMenuItem("Item " + i, new Rectangle(10, 10));
item.setId(item.getText());
item.setToggleGroup(group);
getItems().add(item);
}
setEventHandlers();
}
示例7: MiniViewer
import javafx.scene.control.RadioMenuItem; //导入方法依赖的package包/类
public MiniViewer(final QuPathViewer viewer) {
super(viewer.getImageData(), viewer.getImageRegionStore(), viewer.getOverlayOptions());
setViewer(viewer);
RadioMenuItem[] radioItems = new RadioMenuItem[]{
ActionUtils.createRadioMenuItem(createDownsampleAction("200 %", this, 0.5)),
ActionUtils.createRadioMenuItem(createDownsampleAction("100 %", this, 1)),
ActionUtils.createRadioMenuItem(createDownsampleAction("50 %", this, 2)),
ActionUtils.createRadioMenuItem(createDownsampleAction("25 %", this, 4)),
ActionUtils.createRadioMenuItem(createDownsampleAction("20 %", this, 5)),
ActionUtils.createRadioMenuItem(createDownsampleAction("10 %", this, 10)),
ActionUtils.createRadioMenuItem(createDownsampleAction("Zoom to fit", this, -1))
};
ToggleGroup group = new ToggleGroup();
for (RadioMenuItem item : radioItems)
item.setToggleGroup(group);
popup.getItems().addAll(
ActionUtils.createCheckMenuItem(QuPathGUI.createSelectableCommandAction(synchronizeToMainViewer, "Synchronize to main viewer")),
new SeparatorMenuItem()
);
popup.getItems().addAll(radioItems);
getView().setOnContextMenuRequested(e -> {
popup.show((Node)e.getSource(), e.getScreenX(), e.getScreenY());
});
}
示例8: initialize
import javafx.scene.control.RadioMenuItem; //导入方法依赖的package包/类
public void initialize(URL location, ResourceBundle resources) {
languageMenu.getItems().clear();
Locale localInPref = mainApp.getLocale();
for(Entry<String, Locale> localeEntry : mainApp.locales.entrySet()) {
RadioMenuItem languageMenuItem = new RadioMenuItem(localeEntry.getKey());
if(localeEntry.getValue().equals(localInPref)) {
languageMenuItem.setSelected(true);
}
languageMenuItem.setToggleGroup(languageRadioMenuItemGroup);
languageMenu.getItems().add(languageMenuItem);
languageMenuItem.setOnAction(event -> onChangeLanguage(event));
}
themeMenu.getItems().clear();
String themeInPref = mainApp.getTheme();
for(Entry<String, String> themeEntry : mainApp.themes.entrySet()) {
RadioMenuItem themeMenuItem = new RadioMenuItem(themeEntry.getKey());
if(themeEntry.getValue().equals(themeInPref)) {
themeMenuItem.setSelected(true);
}
themeMenuItem.setToggleGroup(themeRadioMenuItemGroup);
themeMenu.getItems().add(themeMenuItem);
themeMenuItem.setOnAction(event -> onChangeTheme(event));
}
certMenu.getItems().clear();
String certInPref = mainApp.getCert();
for(Entry<String, CertInfo> certEntry : mainApp.certs.entrySet()) {
RadioMenuItem certMenuItem = new RadioMenuItem(certEntry.getKey());
if(certEntry.getKey().equals(certInPref)) {
certMenuItem.setSelected(true);
certInfo = certEntry.getValue();
}
certMenuItem.setToggleGroup(certRadioMenuItemGroup);
certMenu.getItems().add(certMenuItem);
certMenuItem.setOnAction(event -> onChangeCert(event));
}
}
示例9: ready
import javafx.scene.control.RadioMenuItem; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public void ready() {
// Add Listeners
getWindowManager().addCPUChangedListener(this);
cpu = getWindowManager().getCPU();
cpu.registerListener(listener);
// Create Name column
TableColumn<Data, String> registerName = new TableColumn<>("Name");
registerName.setCellValueFactory(new PropertyValueFactory<>("name"));
// Create Number column
TableColumn<Data, String> registerID = new TableColumn<>("ID");
registerID.setCellValueFactory(new PropertyValueFactory<>("id"));
// Create value column
valueCol = new TableColumn<>(valueType.toString());
valueCol.setCellValueFactory(new PropertyValueFactory<>("value"));
// Right Click on value column menu
ContextMenu menu = new ContextMenu();
ToggleGroup toggleGroup = new ToggleGroup();
for (ValueType type : ValueType.values()) {
RadioMenuItem item = new RadioMenuItem(type.toString());
item.setSelected(type.equals(valueType));
item.setOnAction(e -> {
valueType = type;
valueCol.setText(type.toString());
refreshTable();
});
item.setToggleGroup(toggleGroup);
menu.getItems().add(item);
}
valueCol.setContextMenu(menu);
refreshTable();
table.getColumns().addAll(registerName, registerID, valueCol);
table.setEditable(false);
// Refresh registers regularly
refreshTimer = new Timer(true);
refreshTimer.schedule(new TimerTask() {
@Override
public void run() {
refreshRegisters();
}
}, 0, 30);
getContentPane().getChildren().add(table);
super.ready();
}
示例10: createRadioMenuItem
import javafx.scene.control.RadioMenuItem; //导入方法依赖的package包/类
private static RadioMenuItem createRadioMenuItem(final Action action, final ToggleGroup group) {
RadioMenuItem menuItem = ActionUtils.createRadioMenuItem(action);
menuItem.setToggleGroup(group);
return bindVisibilityForExperimental(menuItem);
}