本文整理匯總了Java中javafx.scene.control.SeparatorMenuItem類的典型用法代碼示例。如果您正苦於以下問題:Java SeparatorMenuItem類的具體用法?Java SeparatorMenuItem怎麽用?Java SeparatorMenuItem使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
SeparatorMenuItem類屬於javafx.scene.control包,在下文中一共展示了SeparatorMenuItem類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: populateMenuItems
import javafx.scene.control.SeparatorMenuItem; //導入依賴的package包/類
private void populateMenuItems(ContextMenu contextMenu, Tab tab) {
int tabCount = getTabs().size();
int tabIndex = getTabs().indexOf(tab);
ObservableList<MenuItem> items = contextMenu.getItems();
items.clear();
MenuItem closeMenuItem = new MenuItem("Close");
closeMenuItem.setOnAction((e) -> requestClose(tab));
items.add(closeMenuItem);
if (tabCount > 1) {
MenuItem closeRestMenuItem = new MenuItem("Close Others");
closeRestMenuItem.setOnAction((e) -> closeOtherTabs(tab));
items.add(closeRestMenuItem);
}
if (tabCount > 1 && tabIndex != 0) {
MenuItem closeLeftTabsMenuItem = new MenuItem("Close Tabs to the Left");
closeLeftTabsMenuItem.setOnAction((e) -> closeTabsToLeft(tab));
items.add(closeLeftTabsMenuItem);
}
if (tabCount > 1 && tabIndex != tabCount - 1) {
MenuItem closeRigthTabsMenuItem = new MenuItem("Close Tabs to the Right");
closeRigthTabsMenuItem.setOnAction((e) -> closeTabsToRight(tab));
items.add(closeRigthTabsMenuItem);
}
if (tabCount > 1) {
MenuItem closeAllMenuItem = new MenuItem("Close All");
closeAllMenuItem.setOnAction((e) -> closeAllTabs());
items.addAll(new SeparatorMenuItem(), closeAllMenuItem);
}
}
示例2: menuPath
import javafx.scene.control.SeparatorMenuItem; //導入依賴的package包/類
@Test public void menuPath() {
List<String> path = new ArrayList<>();
Platform.runLater(() -> {
Menu menuFile = new Menu("File");
MenuItem add = new MenuItem("Shuffle");
MenuItem clear = new MenuItem("Clear");
MenuItem exit = new MenuItem("Exit");
menuFile.getItems().addAll(add, clear, new SeparatorMenuItem(), exit);
RFXMenuItem rfxMenuItem = new RFXMenuItem(null, null);
path.add(rfxMenuItem.getSelectedMenuPath(clear));
});
new Wait("Waiting for menu selection path") {
@Override public boolean until() {
return path.size() > 0;
}
};
AssertJUnit.assertEquals("File>>Clear", path.get(0));
}
示例3: menuItemIconNoText
import javafx.scene.control.SeparatorMenuItem; //導入依賴的package包/類
@Test public void menuItemIconNoText() {
List<String> path = new ArrayList<>();
Platform.runLater(() -> {
Menu menuFile = new Menu("File");
MenuItem add = new MenuItem("Shuffle");
MenuItem clear = new MenuItem();
clear.setGraphic(new ImageView(RFXTabPaneTest.imgURL.toString()));
MenuItem exit = new MenuItem("Exit");
menuFile.getItems().addAll(add, clear, new SeparatorMenuItem(), exit);
RFXMenuItem rfxMenuItem = new RFXMenuItem(null, null);
path.add(rfxMenuItem.getSelectedMenuPath(clear));
});
new Wait("Waiting for menu selection path") {
@Override public boolean until() {
return path.size() > 0;
}
};
AssertJUnit.assertEquals("File>>middle", path.get(0));
}
示例4: duplicateMenuPath
import javafx.scene.control.SeparatorMenuItem; //導入依賴的package包/類
@Test public void duplicateMenuPath() {
List<String> path = new ArrayList<>();
Platform.runLater(() -> {
Menu menuFile = new Menu("File");
MenuItem add = new MenuItem("Shuffle");
MenuItem clear = new MenuItem("Clear");
MenuItem clear1 = new MenuItem("Clear");
MenuItem clear2 = new MenuItem("Clear");
MenuItem exit = new MenuItem("Exit");
menuFile.getItems().addAll(add, clear, clear1, clear2, new SeparatorMenuItem(), exit);
RFXMenuItem rfxMenuItem = new RFXMenuItem(null, null);
path.add(rfxMenuItem.getSelectedMenuPath(clear2));
});
new Wait("Waiting for menu selection path") {
@Override public boolean until() {
return path.size() > 0;
}
};
AssertJUnit.assertEquals("File>>Clear(2)", path.get(0));
}
示例5: FileTreeMenu
import javafx.scene.control.SeparatorMenuItem; //導入依賴的package包/類
public FileTreeMenu(FileTreeView view) {
this.view = view;
this.setOnShowing(event -> {
Log.trace("Show Context Menu");
FileTreeNode node = view.getSelected();
if (node == null) {
this.getItems().clear();
} else {
try {
node.updateMenu(view.getViewer(), this);
} catch (Exception e) {
Log.error(e);
ViewerAlert.exceptionAlert(e);
this.getItems().clear();
}
}
});
this.getItems().add(new SeparatorMenuItem());
}
示例6: addMenu
import javafx.scene.control.SeparatorMenuItem; //導入依賴的package包/類
public void addMenu(final String name, final MenuCategory... menuCats)
{
final Menu newItem = new MenuTranslate(name);
// add menus
for (final MenuCategory mc : menuCats)
// check if category is not empty
if (mc.getItems().size() > 0)
{
// add a separator
if (newItem.getItems().size() != 0)
newItem.getItems().add(new SeparatorMenuItem());
// add all menu items
newItem.getItems().addAll(mc.getItems());
}
this.listMenu.add(newItem);
this.menu.getMenus().add(newItem);
}
示例7: initialize
import javafx.scene.control.SeparatorMenuItem; //導入依賴的package包/類
public void initialize() {
MenuBar menuBar = new MenuBar();
// Make same width as the stage
menuBar.prefWidthProperty().bind(primaryStage.widthProperty());
rootPane.setTop(menuBar);
// File menu - new, save, exit
Menu fileMenu = new Menu("File");
MenuItem newMenuItem = createMenuItem("New", actionEvent -> this.onNewFile());
MenuItem openMenuItem = createMenuItem("Open", actionEvent -> this.onOpenFile());
MenuItem saveMenuItem = createMenuItem("Save", actionEvent -> this.onSaveFile());
saveMenuItem.disableProperty().bind(jwkSetData.changedProperty().not());
MenuItem exitMenuItem = createMenuItem("Exit", actionEvent -> Platform.exit());
fileMenu.getItems().addAll(newMenuItem, openMenuItem, saveMenuItem,
new SeparatorMenuItem(), exitMenuItem);
menuBar.getMenus().addAll(fileMenu);
}
示例8: GoogleEntryAttendeeItem
import javafx.scene.control.SeparatorMenuItem; //導入依賴的package包/類
public GoogleEntryAttendeeItem(EventAttendee attendee) {
this.attendee = Objects.requireNonNull(attendee);
optionalIcon = new Label();
optionalIcon.setOnMouseClicked(evt -> setOptional(!isOptional()));
optionalIcon.getStyleClass().add("button-icon");
optionalIcon.setTooltip(new Tooltip());
statusIcon = new Label();
name = new Label();
name.setMaxWidth(Double.MAX_VALUE);
setOptional(Boolean.TRUE.equals(attendee.getOptional()));
optionalProperty().addListener(obs -> updateIcon());
updateIcon();
removeButton = new Label();
removeButton.setGraphic(new FontAwesome().create(FontAwesome.Glyph.TRASH_ALT));
removeButton.getStyleClass().add("button-icon");
removeButton.setOnMouseClicked(evt -> removeAttendee(attendee));
HBox.setHgrow(optionalIcon, Priority.NEVER);
HBox.setHgrow(name, Priority.ALWAYS);
HBox.setHgrow(removeButton, Priority.NEVER);
getStyleClass().add("attendee-item");
getChildren().addAll(optionalIcon, statusIcon, name, removeButton);
ContextMenu menu = new ContextMenu();
MenuItem optionalItem = new MenuItem("Mark as optional");
optionalItem.setOnAction(evt -> setOptional(true));
MenuItem requiredItem = new MenuItem("Mark as required");
requiredItem.setOnAction(evt -> setOptional(false));
MenuItem removeItem = new MenuItem("Remove attendee");
removeItem.setOnAction(evt -> removeAttendee(attendee));
menu.getItems().addAll(optionalItem, requiredItem, new SeparatorMenuItem(), removeItem);
addEventHandler(CONTEXT_MENU_REQUESTED, evt -> menu.show(this, evt.getScreenX(), evt.getScreenY()));
}
示例9: initTableContextMenu
import javafx.scene.control.SeparatorMenuItem; //導入依賴的package包/類
private void initTableContextMenu() {
TextField textField = new TextField("Type Something"); // we will add a popup menu to this text field
contextMenu = new ContextMenu();
MenuItem pauseP = new MenuItem("Stop process");
pauseP.setId("pausep");
MenuItem continueP = new MenuItem("Continue process");
continueP.setId("continuep");
MenuItem killP = new MenuItem("Kill process");
killP.setId("killp");
pauseP.setOnAction(actionEventHandler);
continueP.setOnAction(actionEventHandler);
killP.setOnAction(actionEventHandler);
contextMenu.getItems().addAll(pauseP, continueP, new SeparatorMenuItem(), killP);
// ...
textField.setContextMenu(contextMenu);
}
示例10: createFileMenu
import javafx.scene.control.SeparatorMenuItem; //導入依賴的package包/類
private Menu createFileMenu() {
Menu menuFile = new Menu("File");
menuFileNew = new Menu("New");
menuFileGenerators = new Menu("Generators");
// "Save" is initially disabled because we do not have a structure.
menuFileSave = createMenuItem("Save graph as...", handlers.onSave);
menuFileSave.setDisable(true);
menuFile.getItems().addAll(
menuFileNew, menuFileGenerators,
createMenuItem("Open graph...", handlers.onOpen),
createMenuItem("Direct input...", handlers.onDirectInput),
menuFileSave,
new SeparatorMenuItem(),
createMenuItem("Load plugin...", handlers.onLoadPlugin),
new SeparatorMenuItem(),
createMenuItem("Exit", handlers.onExit));
return menuFile;
}
示例11: configureRecentFilesMenu
import javafx.scene.control.SeparatorMenuItem; //導入依賴的package包/類
/**
* Binds the recent files menu to the recent files in the config.
*/
private void configureRecentFilesMenu() {
ListChangeListener<String> updateRecentFilesMenu = change -> {
ObservableList<MenuItem> items = recentFilesMenu.getItems();
items.clear();
if (config.getState().getRecentFiles().isEmpty()) {
MenuItem noItem = new MenuItem("No recent file");
noItem.setDisable(true);
items.add(noItem);
} else {
config.getState().getRecentFiles().stream().map(path -> {
MenuItem menuItem = new MenuItem(path);
menuItem.setOnAction(event -> openRecentFile(path));
return menuItem;
}).forEach(items::add);
MenuItem sep = new SeparatorMenuItem();
items.add(sep);
MenuItem clearItem = new MenuItem("Clear recent files");
clearItem.setOnAction(event -> config.getState().getRecentFiles().clear());
items.add(clearItem);
}
};
config.getState().getRecentFiles().addListener(updateRecentFilesMenu);
// manual trigger the first time for initialization
updateRecentFilesMenu.onChanged(null);
}
示例12: selectionCycle
import javafx.scene.control.SeparatorMenuItem; //導入依賴的package包/類
protected void selectionCycle(boolean enabled, boolean event) {
clearLastSelectedBtn.mouse().click();
clearLastEventBtn.mouse().click();
Wrap<? extends Menu> menu = menuBarLookup.lookup(new MenuByText(MenuItemApp.MIXED_ID)).wrap();
Parent<MenuItem> menu_as_parent = menu.as(Parent.class, MenuItem.class);
for (int i = 0; i < menu_as_parent.lookup().size(); i++) {
menu_as_parent = menu.as(Parent.class, MenuItem.class);
Wrap<? extends MenuItem> item_wrap = menu_as_parent.lookup().wrap(i);
MenuItem item = item_wrap.getControl();
if (SeparatorMenuItem.class.isInstance(item)) {
continue;
}
expand(menu, true);
item_wrap.mouse().click();
lastSelected.waitProperty(Wrap.TEXT_PROP_NAME, enabled ? item.getId() : "");
lastEvent.waitProperty(Wrap.TEXT_PROP_NAME, event ? item.getId() : "");
}
}
示例13: themeMenu
import javafx.scene.control.SeparatorMenuItem; //導入依賴的package包/類
/**
* Dynamically generates the Theme menu.
*
* @param menu
* The menu item to attach to
* @return The completed menu
*/
private Menu themeMenu(Menu menu) {
menu.getItems().clear();
for (Theme t : wm.getThemes()) {
MenuItem item = new MenuItem(t.getName());
item.setOnAction(e -> wm.getThemes().setTheme(t));
menu.getItems().add(item);
}
MenuItem reloadThemeItem = new MenuItem("Refresh Themes");
reloadThemeItem.setOnAction(e -> {
wm.getThemes().reload();
themeMenu(menu);
wm.getThemes().setTheme(wm.getThemes().getTheme());
});
menu.getItems().addAll(new SeparatorMenuItem(), reloadThemeItem);
return menu;
}
示例14: windowsMenuHelper
import javafx.scene.control.SeparatorMenuItem; //導入依賴的package包/類
/**
* Dynamically generates the windows menu items
*
* @param windowsMenu
* The windows menu to add the items to
*/
private void windowsMenuHelper(Menu windowsMenu) {
windowsMenu.getItems().clear();
for (WindowEnum wenum : WindowEnum.values()) {
if (wenum.showInWindowsMenu()) {
CheckMenuItem item = new CheckMenuItem(wenum.toString());
item.setSelected(wm.getWorkspace().windowIsOpen(wenum));
item.setOnAction(e -> {
InternalWindow window = wm.getWorkspace().findInternalWindow(wenum);
if (window == null)
wm.getWorkspace().openInternalWindow(wenum);
else
window.close();
});
windowsMenu.getItems().add(item);
}
}
MenuItem delWindows = new MenuItem("Close All");
delWindows.setOnAction(e -> wm.getWorkspace().closeAll());
windowsMenu.getItems().addAll(new SeparatorMenuItem(), delWindows);
}
示例15: applyControls
import javafx.scene.control.SeparatorMenuItem; //導入依賴的package包/類
/**
* Method to apply the functions available to the menu.
*/
private void applyControls() {
rightWallControl = new MenuItem( HIDE_RIGHT );
rightWallControl.setOnAction( event -> controlRightWall( display, rightWallControl ) );
leftWallControl = new MenuItem( HIDE_LEFT );
leftWallControl.setOnAction( event -> controlLeftWall( display, leftWallControl ) );
imageFlasherControl = new MenuItem( CONFIGURE_IMAGE_FLASHER );
imageFlasherControl.setOnAction( event -> display.showImageFlasherConfiguration() );
MenuItem hideConfig = new MenuItem( HIDE_CONFIGURATION );
hideConfig.setOnAction( event -> display.hideConfiguration() );
getItems().addAll(
leftWallControl,
rightWallControl,
new SeparatorMenuItem(),
imageFlasherControl,
hideConfig
);
}