本文整理汇总了Java中javafx.scene.control.MenuItem.setText方法的典型用法代码示例。如果您正苦于以下问题:Java MenuItem.setText方法的具体用法?Java MenuItem.setText怎么用?Java MenuItem.setText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.control.MenuItem
的用法示例。
在下文中一共展示了MenuItem.setText方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: rebuildAddItemMenu
import javafx.scene.control.MenuItem; //导入方法依赖的package包/类
private void rebuildAddItemMenu() {
Station station = conjunction.getFormula().getContext().getStation();
addEntry.getItems().clear();
for(String id : station.getFilters().keySet()) {
MenuItem item = new MenuItem();
item.setText(id);
item.setOnAction(event -> {
if(!content.getItems().contains(id)) {
content.getItems().add(id);
}
});
addEntry.getItems().add(item);
}
}
示例2: createMenuItem
import javafx.scene.control.MenuItem; //导入方法依赖的package包/类
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;
}
示例3: createCheckboxMenuItem
import javafx.scene.control.MenuItem; //导入方法依赖的package包/类
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;
}
示例4: getSimpleMenuItem
import javafx.scene.control.MenuItem; //导入方法依赖的package包/类
public static MenuItem getSimpleMenuItem(String text, Node graphic, Consumer<ActionEvent> eventHandler) {
MenuItem item = new MenuItem();
if (text != null) {
item.setText(text);
}
if (graphic != null) {
item.setGraphic(graphic);
}
if (eventHandler != null) {
item.setOnAction(eventHandler::accept);
}
return item;
}
示例5: getRecentMenuItemPair
import javafx.scene.control.MenuItem; //导入方法依赖的package包/类
private Pair<File, MenuItem> getRecentMenuItemPair(File file) {
MenuItem item = new MenuItem();
item.setText(file.toString());
item.setOnAction(e -> onAction.accept(file));
return new Pair<>(file, item);
}
示例6: initialize
import javafx.scene.control.MenuItem; //导入方法依赖的package包/类
@Override
public void initialize(URL location, ResourceBundle resources)
{
if (prefs.get(PreferencesKeys.SAVE_PATH.toString(), null) != null)
{
try
{
userAppList.loadFromXml(new File(prefs.get(PreferencesKeys.SAVE_PATH.toString(), null)));
} catch (JAXBException | SteamApiException e)
{
e.printStackTrace();
}
}
currentAppList = userAppList.getAppList();
updateListApp();
/* Define the Table View */
key.setCellValueFactory(new PropertyValueFactory<>("key"));
key.setCellFactory(TextFieldTableCell.forTableColumn());
state.setCellValueFactory(new PropertyValueFactory<>("state"));
state.setCellFactory(ComboBoxTableCell.forTableColumn(KeyState.values()));
currentUse.setCellValueFactory(new PropertyValueFactory<>("currentUse"));
currentUse.setCellFactory(ComboBoxTableCell.forTableColumn(KeyCurrentUse.values()));
used.setCellValueFactory(new PropertyValueFactory<>("used"));
used.setCellFactory(CheckBoxTableCell.forTableColumn(used));
dateAdded.setCellValueFactory(new PropertyValueFactory<>("dateAdded"));
dateAdded.setCellFactory(TextFieldTableCell.forTableColumn());
/*Change listener for table view */
ChangeListener<Object> listener = (obs, oldValue, newValue) ->
modified = true;
keyList.focusedProperty().addListener(listener);
keyList.getSelectionModel().selectedItemProperty().addListener(listener);
/* Context Menu for the filter button */
ContextMenu contextMenu = new ContextMenu();
MenuItem showAll = new MenuItem();
MenuItem showUsed = new MenuItem();
showAll.setText(I18n.getMessage("allGame"));
showUsed.setText(I18n.getMessage("gameWithUsedKey"));
showAll.setOnAction(event ->
{
currentAppList = userAppList.getAppList();
updateListApp();
filterMode = false;
});
showUsed.setOnAction(event ->
{
currentAppList = userAppList.getGamesWithUsedKey();
updateListApp();
filterMode = true;
});
contextMenu.getItems().addAll(showAll,showUsed);
filterButton.setContextMenu(contextMenu);
imageCacheHandler.loadImageCache();
}