Java Code Examples for javafx.scene.control.MenuItem#setText()

The following examples show how to use javafx.scene.control.MenuItem#setText() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BrokerConfigView.java    From kafka-message-tool with MIT License 6 votes vote down vote up
private void bindPopupMenuToSelectedRow(KafkaClusterProxy proxy, TableRow<TopicAggregatedSummary> row) {

        final MenuItem deleteTopicMenuItem = createMenuItemForDeletingTopic();
        final MenuItem createTopicMenuItem = createMenuItemForCreatingNewTopic();
        final MenuItem alterTopicMenuItem = createMenuItemForAlteringTopic();
        final MenuItem topicPropertiesMenuItem = createMenuItemForShowingTopicProperties();

        final ContextMenu contextMenu = getTopicManagementContextMenu(deleteTopicMenuItem,
                                                                      createTopicMenuItem,
                                                                      alterTopicMenuItem,
                                                                      topicPropertiesMenuItem);

        row.contextMenuProperty().bind(new ReadOnlyObjectWrapper<>(contextMenu));
        topicPropertiesMenuItem.disableProperty().bind(row.emptyProperty());

        if (proxy.isTopicDeletionEnabled() != TriStateConfigEntryValue.True) {
            deleteTopicMenuItem.setText("Delete topic (disabled by broker)");
            deleteTopicMenuItem.disableProperty().setValue(true);
        } else {
            deleteTopicMenuItem.disableProperty().bind(row.emptyProperty());
        }
        alterTopicMenuItem.disableProperty().bind(row.emptyProperty());
    }
 
Example 2
Source File: MainDesignerController.java    From pmd-designer with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void updateRecentFilesMenu() {
    List<MenuItem> items = new ArrayList<>();
    List<File> filesToClear = new ArrayList<>();

    for (final File f : recentFiles) {
        if (f.exists() && f.isFile()) {
            CustomMenuItem item = new CustomMenuItem(new Label(f.getName()));
            item.setOnAction(e -> loadSourceFromFile(f));
            item.setMnemonicParsing(false);
            Tooltip.install(item.getContent(), new Tooltip(f.getAbsolutePath()));
            items.add(item);
        } else {
            filesToClear.add(f);
        }
    }
    recentFiles.removeAll(filesToClear);

    if (items.isEmpty()) {
        openRecentMenu.setDisable(true);
        return;
    }

    Collections.reverse(items);

    items.add(new SeparatorMenuItem());
    MenuItem clearItem = new MenuItem();
    clearItem.setText("Clear menu");
    clearItem.setOnAction(e -> {
        recentFiles.clear();
        openRecentMenu.setDisable(true);
    });
    items.add(clearItem);

    openRecentMenu.getItems().setAll(items);
}
 
Example 3
Source File: OnlyTrayIconDemo.java    From oim-fx with MIT License 5 votes vote down vote up
private void enableTray(final Stage stage) {
	try {
		ContextMenu menu = new ContextMenu();

		MenuItem updateMenuItem = new MenuItem();
		MenuItem showMenuItem = new MenuItem();
		showMenuItem.setText("查看群信息");
		updateMenuItem.setText("修改群信息");
		menu.getItems().add(showMenuItem);
		menu.getItems().add(updateMenuItem);
		menu.getItems().add(new MenuItem("好好的事实的话"));
		menu.getItems().add(new MenuItem("好好的事实的话"));
		menu.getItems().add(new MenuItem("好好的事实的话"));
		menu.getItems().add(new MenuItem("好好的事实的话"));
		menu.getItems().add(new MenuItem("好好的事实的话"));

		SystemTray tray = SystemTray.getSystemTray();
		BufferedImage image = ImageIO.read(OnlyTrayIconDemo.class.getResourceAsStream("tray.png"));
		// Image image = new
		// ImageIcon("Resources/Images/Logo/logo_16.png").getImage();
		trayIcon = new OnlyTrayIcon(image, "自动备份工具");
		trayIcon.setToolTip("自动备份工具");
		trayIcon.setContextMenu(menu);
		tray.add(trayIcon);
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
Example 4
Source File: FXUIUtils.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public static MenuItem createMenuItem(String name, String commandName, String mnemonic) {
    MenuItem menuItem = new MenuItem();
    menuItem.setId(name + "MenuItem");
    Node enabledIcon = getImageFrom(name, "icons/", FromOptions.NULL_IF_NOT_EXISTS);
    if (enabledIcon != null) {
        menuItem.setGraphic(enabledIcon);
    }
    menuItem.setText(commandName);
    if (!"".equals(mnemonic)) {
        menuItem.setAccelerator(KeyCombination.keyCombination(mnemonic));
    }

    return menuItem;
}
 
Example 5
Source File: FXUIUtils.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public static MenuItem createCheckboxMenuItem(String name, String commandName, String mnemonic) {
    MenuItem menuItem = new CheckMenuItem();
    menuItem.setId(name + "MenuItem");
    Node enabledIcon = getImageFrom(name, "icons/", FromOptions.NULL_IF_NOT_EXISTS);
    if (enabledIcon != null) {
        menuItem.setGraphic(enabledIcon);
    }
    menuItem.setText(commandName);
    if (!"".equals(mnemonic)) {
        menuItem.setAccelerator(KeyCombination.keyCombination(mnemonic));
    }
    return menuItem;
}
 
Example 6
Source File: DisplayEditor.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
private MenuItem createMenuItem(final ActionDescription action)
{
    final MenuItem item = new MenuItem();
    try
    {
        item.setGraphic(ImageCache.getImageView(action.getIconResourcePath()));
    }
    catch (final Exception ex)
    {
        logger.log(Level.WARNING, "Cannot load action icon", ex);
    }
    item.setText(action.getToolTip());
    item.setOnAction(event -> action.run(this));
    return item;
}
 
Example 7
Source File: EyePhotoPairNode.java    From Augendiagnose with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create the context menu for the date.
 *
 * @return the context menu.
 */
private ContextMenu createDateContextMenu() {
	ContextMenu menu = new ContextMenu();

	MenuItem menuItemRemove = new MenuItem();
	menuItemRemove.setText(ResourceUtil.getString(ResourceConstants.MENU_DELETE_IMAGES));

	menuItemRemove.setOnAction(new EventHandler<ActionEvent>() {
		@Override
		public void handle(final ActionEvent event) {
			DialogUtil.displayConfirmationMessage(new ConfirmDialogListener() {

				@Override
				public void onDialogPositiveClick() {
					mParentController.removeItem(EyePhotoPairNode.this);
					mPair.delete();
				}

				@Override
				public void onDialogNegativeClick() {
					// do nothing
				}
			}, ResourceConstants.BUTTON_DELETE,
					ResourceConstants.MESSAGE_DIALOG_CONFIRM_DELETE_DATE, mPair.getPersonName(), mLabelDate.getText());
		}
	});
	menu.getItems().add(menuItemRemove);

	return menu;
}
 
Example 8
Source File: SelectionTableToolbar.java    From pdfsam with GNU Affero General Public License v3.0 5 votes vote down vote up
public AddButton(String ownerModule) {
    this.ownerModule = defaultString(ownerModule);
    getStyleClass().addAll(Style.BUTTON.css());
    getStyleClass().addAll("pdfsam-split-button", "toolbar-splitbutton");
    setTooltip(new Tooltip(DefaultI18nContext.getInstance().i18n("Add documents to the table")));
    setText(DefaultI18nContext.getInstance().i18n("_Add"));
    setOnAction(this::loadDocuments);

    MenuItem fromList = new MenuItem();
    fromList.setText(DefaultI18nContext.getInstance().i18n("PDF list from _text/csv file"));
    fromList.setOnAction(this::loadList);
    getItems().add(fromList);
}
 
Example 9
Source File: SelectionTableToolbar.java    From pdfsam with GNU Affero General Public License v3.0 5 votes vote down vote up
public ClearButton(String ownerModule) {
    setId("clear-button");
    this.ownerModule = defaultString(ownerModule);
    getStyleClass().addAll(Style.BUTTON.css());
    getStyleClass().addAll("pdfsam-split-button", "toolbar-splitbutton");
    setTooltip(new Tooltip(DefaultI18nContext.getInstance().i18n("Removes every document")));
    setText(DefaultI18nContext.getInstance().i18n("_Clear"));
    setOnAction(this::clear);

    MenuItem clearAllSettings = new MenuItem();
    clearAllSettings.setText(DefaultI18nContext.getInstance().i18n("C_lear all settings"));
    clearAllSettings.setOnAction(this::clearAll);
    getItems().add(clearAllSettings);
}
 
Example 10
Source File: DisplayPhotosController.java    From Augendiagnose with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create the context menu when clicking on a name.
 *
 * @param name The name.
 * @return The context menu.
 */
private ContextMenu createContextMenu(final String name) {
	ContextMenu menu = new ContextMenu();

	MenuItem menuItemRemove = new MenuItem();
	menuItemRemove.setText(ResourceUtil.getString(ResourceConstants.MENU_DELETE_IMAGES));

	menuItemRemove.setOnAction(new EventHandler<ActionEvent>() {
		@Override
		public void handle(final ActionEvent event) {
			DialogUtil.displayConfirmationMessage(new ConfirmDialogListener() {

				@Override
				public void onDialogPositiveClick() {
					File folder = new File(new File(PreferenceUtil.getPreferenceString(KEY_FOLDER_PHOTOS)), name);
					File[] children = folder.listFiles();
					if (children != null) {
						for (File child : children) {
							child.delete();
						}
					}
					folder.delete();

					if (name.equals(PreferenceUtil.getPreferenceString(KEY_LAST_NAME))) {
						PreferenceUtil.removePreference(KEY_LAST_NAME);
					}
					initializeNames("", true);
				}

				@Override
				public void onDialogNegativeClick() {
					// do nothing
				}
			}, ResourceConstants.BUTTON_DELETE,
					ResourceConstants.MESSAGE_DIALOG_CONFIRM_DELETE_FOLDER, name);
		}
	});
	menu.getItems().add(menuItemRemove);

	return menu;
}