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


Java RadioMenuItem.setOnAction方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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;
}
 
开发者ID:macroing,项目名称:Dayflower-Path-Tracer,代码行数:10,代码来源:JavaFX.java

示例5: createContextMenu

import javafx.scene.control.RadioMenuItem; //导入方法依赖的package包/类
private ContextMenu createContextMenu() {
    ContextMenu contextMenu = new ContextMenu();
    MenuItem newEntry = new MenuItem(Messages.getString("MonthSheetView.ADD_NEW_EVENT")); //$NON-NLS-1$
    newEntry.setOnAction(evt -> {

        LocalDate date = getDateSelectionModel().getLastSelected();
        Entry<?> entry = createEntryAt(ZonedDateTime.of(date, LocalTime.of(12, 0), getZoneId()));

        Callback<EntryDetailsParameter, Boolean> callback = getEntryDetailsCallback();
        EntryDetailsParameter param = new EntryDetailsParameter(null, this, entry, dateCell, ctxMenuScreenX, ctxMenuScreenY);
        callback.call(param);

    });
    contextMenu.getItems().add(newEntry);

    contextMenu.getItems().add(new SeparatorMenuItem());

    RadioMenuItem standardCellItem = new RadioMenuItem(Messages.getString("MonthSheetView.STANDARD_CELLS"));
    RadioMenuItem detailCellItem = new RadioMenuItem(Messages.getString("MonthSheetView.DETAIL_CELLS"));
    RadioMenuItem usageCellItem = new RadioMenuItem(Messages.getString("MonthSheetView.USAGE_CELLS"));
    RadioMenuItem badgeCellItem = new RadioMenuItem(Messages.getString("MonthSheetView.BADGE_CELLS"));

    standardCellItem.setOnAction(evt -> setCellFactory(param -> new SimpleDateCell(param.getView(), param.getDate())));
    detailCellItem.setOnAction(evt -> setCellFactory(param -> new DetailedDateCell(param.getView(), param.getDate())));
    usageCellItem.setOnAction(evt -> setCellFactory(param -> new UsageDateCell(param.getView(), param.getDate())));
    badgeCellItem.setOnAction(evt -> setCellFactory(param -> new BadgeDateCell(param.getView(), param.getDate())));

    ToggleGroup group = new ToggleGroup();
    group.getToggles().addAll(standardCellItem, detailCellItem, usageCellItem, badgeCellItem);

    contextMenu.getItems().addAll(standardCellItem, detailCellItem, usageCellItem, badgeCellItem);

    standardCellItem.setSelected(true);

    return contextMenu;
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:37,代码来源:MonthSheetView.java

示例6: 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;
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:38,代码来源:GoogleCalendarAppViewSkin.java

示例7: 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;
}
 
开发者ID:xframium,项目名称:xframium-java,代码行数:14,代码来源:FontManagerType1.java

示例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));
	}
}
 
开发者ID:liudonghua123,项目名称:signapk_fx,代码行数:39,代码来源:MainPaneController.java

示例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();
}
 
开发者ID:mbway,项目名称:Simulizer,代码行数:55,代码来源:Registers.java


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