本文整理汇总了Java中javafx.scene.control.Menu类的典型用法代码示例。如果您正苦于以下问题:Java Menu类的具体用法?Java Menu怎么用?Java Menu使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Menu类属于javafx.scene.control包,在下文中一共展示了Menu类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getOGSMenu
import javafx.scene.control.Menu; //导入依赖的package包/类
private Menu getOGSMenu() {
Menu ogsMenu = new Menu("OGS");
MenuItem ogsGameList = new MenuItem("Game List");
ogsGameList.setOnAction(event -> {
GameListController controller = new GameListController();
DockNode node = controller.getDockNode();
node.setTitle("OGS GameList");
node.dock(dockPane, DockPos.RIGHT);
});
ogsMenu.getItems().add(ogsGameList);
return ogsMenu;
}
示例2: start
import javafx.scene.control.Menu; //导入依赖的package包/类
@Override
public void start(Stage stage) {
stage.setTitle("Vokabeltrainer");
Scene scene = new Scene(new VBox(), 400, 350);
scene.setFill(Color.OLDLACE);
MenuBar menuBar = new MenuBar();
// --- Menu File
Menu menuFile = new Menu("Vokabeln");
MenuItem sample = new MenuItem("Sample");
sample.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
// Do stuff here
}
});
menuFile.getItems().add(sample);
// --- Menu Edit
Menu menuEdit = new Menu("Abfragemodus");
// --- Menu View
Menu menuView = new Menu("Statistik");
menuBar.getMenus().addAll(menuFile, menuEdit, menuView);
((VBox) scene.getRoot()).getChildren().addAll(menuBar);
stage.setScene(scene);
stage.show();
}
示例3: getWSMenu
import javafx.scene.control.Menu; //导入依赖的package包/类
private Menu getWSMenu() {
Menu result = new Menu("WSP");
MenuItem editWSPItem = new MenuItem("Edit WSP...", AssetsLoader.getIcon("edit.png"));
MenuItem connectItem = new MenuItem("Sign in...", AssetsLoader.getIcon("discord_icon.png"));
orgManagerItem = new MenuItem("Organization manager...", AssetsLoader.getIcon("wsp_icon.png"));
orgManagerItem.setDisable(true);
connectItem.setOnAction(this::connectToWSPAction);
editWSPItem.setOnAction(this::editWSPAction);
orgManagerItem.setOnAction(this::organizationManagerAction);
result.getItems().add(connectItem);
result.getItems().add(orgManagerItem);
result.getItems().add(editWSPItem);
cam.getWspConnectionRequiredMenuItems().add(orgManagerItem);
cam.getWspNotConnectedRequiredMenuItems().add(connectItem);
cam.getWspNotConnectedRequiredMenuItems().add(editWSPItem);
return result;
}
示例4: testPopulateRecentFilesMenu
import javafx.scene.control.Menu; //导入依赖的package包/类
@SuppressWarnings("unchecked") // needed for the mocking of ObservableList<MenuItem>
@Test
void testPopulateRecentFilesMenu() throws UIInitialisationException, IOException {
// Clean up file history (not in a global @BeforeEach, due to this test being the only test requiring it)
RecentFiles.reset();
final Menu recentFilesMenuMock = mock(Menu.class);
when(recentFilesMenuMock.getItems()).thenReturn((ObservableList<MenuItem>) mock(ObservableList.class));
// Add one test-file
RecentFiles.add(new File("test.gfa"));
menuController.setRecentFilesMenu(recentFilesMenuMock);
menuController.populateRecentFilesMenu();
verify(recentFilesMenuMock.getItems()).add(any(MenuItem.class));
// Clean up file history
RecentFiles.reset();
}
示例5: marathon_select
import javafx.scene.control.Menu; //导入依赖的package包/类
@Override public boolean marathon_select(String value) {
MenuBar menuBar = (MenuBar) node;
ObservableList<Menu> menus = menuBar.getMenus();
String[] items = value.split("\\>\\>");
Menu parentMenu = getParentMenu(menus, items[0]);
List<MenuItem> menuItems = new ArrayList<>();
for (int i = 1; i < items.length; i++) {
getChidernMenuItem(parentMenu, items[i], menuItems);
}
parentMenu.fire();
menuItems.stream().forEach((menu) -> {
if (menu instanceof CheckMenuItem) {
CheckMenuItem checkMenuItem = (CheckMenuItem) menu;
checkMenuItem.setSelected(!checkMenuItem.isSelected());
} else if (menu instanceof RadioMenuItem) {
RadioMenuItem radioMenuItem = (RadioMenuItem) menu;
radioMenuItem.setSelected(!isSelected());
}
menu.fire();
});
return true;
}
示例6: getTagForMenu
import javafx.scene.control.Menu; //导入依赖的package包/类
private String getTagForMenu(MenuItem source) {
LinkedList<MenuItem> menuItems = new LinkedList<>();
while (source != null) {
menuItems.addFirst(source);
source = source.getParentMenu();
}
if (menuItems.getFirst() instanceof Menu) {
if (menuItems.size() >= 2) {
ownerNode = menuItems.get(1).getParentPopup().getOwnerNode();
return isMenuBar(ownerNode) ? "#menu" : "#contextmenu";
}
} else {
ownerNode = menuItems.getFirst().getParentPopup().getOwnerNode();
return "#contextmenu";
}
return null;
}
示例7: menuPath
import javafx.scene.control.Menu; //导入依赖的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));
}
示例8: menuItemIconNoText
import javafx.scene.control.Menu; //导入依赖的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));
}
示例9: subMenuPath
import javafx.scene.control.Menu; //导入依赖的package包/类
@Test public void subMenuPath() {
List<String> path = new ArrayList<>();
Platform.runLater(() -> {
Menu menuEdit = new Menu("Edit");
Menu menuEffect = new Menu("Picture Effect");
final MenuItem noEffects = new MenuItem("No Effects");
menuEdit.getItems().addAll(menuEffect, noEffects);
MenuItem add = new MenuItem("Shuffle");
menuEffect.getItems().addAll(add);
RFXMenuItem rfxMenuItem = new RFXMenuItem(null, null);
path.add(rfxMenuItem.getSelectedMenuPath(add));
});
new Wait("Waiting for menu selection path") {
@Override public boolean until() {
return path.size() > 0;
}
};
AssertJUnit.assertEquals("Edit>>Picture Effect>>Shuffle", path.get(0));
}
示例10: specialChars
import javafx.scene.control.Menu; //导入依赖的package包/类
@Test public void specialChars() {
List<String> path = new ArrayList<>();
Platform.runLater(() -> {
Menu menuView = new Menu("View");
CheckMenuItem titleView = createMenuItem("Tit>le");
CheckMenuItem binNameView = createMenuItem("Binomial name");
CheckMenuItem picView = createMenuItem("Picture");
CheckMenuItem descriptionView = createMenuItem("Decsription");
menuView.getItems().addAll(titleView, binNameView, picView, descriptionView);
RFXMenuItem rfxMenuItem = new RFXMenuItem(null, null);
path.add(rfxMenuItem.getSelectedMenuPath(titleView));
});
new Wait("Waiting for menu selection path") {
@Override public boolean until() {
return path.size() > 0;
}
};
AssertJUnit.assertEquals("View>>Tit\\>le", path.get(0));
}
示例11: duplicateMenuPath
import javafx.scene.control.Menu; //导入依赖的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));
}
示例12: fillContextMenu
import javafx.scene.control.Menu; //导入依赖的package包/类
@Override
@FXThread
public void fillContextMenu(@NotNull final NodeTree<?> nodeTree,
@NotNull final ObservableList<MenuItem> items) {
if (!(nodeTree instanceof ModelNodeTree)) return;
final T element = getElement();
final AssetLinkNode linkNode = findParent(element, AssetLinkNode.class::isInstance);
if (linkNode == null) {
final Menu createMenu = createCreationMenu(nodeTree);
if (createMenu != null) items.add(createMenu);
final Menu toolMenu = createToolMenu(nodeTree);
if (toolMenu != null) items.add(toolMenu);
}
if (linkNode == null || element == linkNode) {
items.add(new AddUserDataAction(nodeTree, this));
}
if (canRemove()) {
items.add(new RemoveNodeAction(nodeTree, this));
}
super.fillContextMenu(nodeTree, items);
}
示例13: addMenu
import javafx.scene.control.Menu; //导入依赖的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);
}
示例14: initialize
import javafx.scene.control.Menu; //导入依赖的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);
}
示例15: onViewCreated
import javafx.scene.control.Menu; //导入依赖的package包/类
@Override
protected void onViewCreated() {
siderBarView.setOnItemSelectedListener(contentView::loadBucket);
contentView.setOnItemSelectedListener(this::updateSelectItem);
contentView.setUpdateListener(bucketFile -> {
if (Platform.isFxApplicationThread()) {
updateSelectItem(bucketFile);
} else {
runOnUiThread(() -> this.updateSelectItem(bucketFile));
}
});
// 初始化菜单
Menu setting = new Menu("设置");
setting.getItems().add(getMenuItem("TinyPNG", "tinypng"));
setting.getItems().add(getMenuItem("七牛", "qiniu"));
setting.getItems().add(getMenuItem("Gif", "gif"));
Menu about = new Menu("关于");
about.getItems().add(getMenuItem("关于BlogHelper", "aboutBlogHelper"));
about.getItems().add(getMenuItem("关于作者cmlanche", "aboutAnchor"));
menuBar.getMenus().add(setting);
menuBar.getMenus().add(about);
if (PlatformUtil.isMac()) {
menuBar.setUseSystemMenuBar(true);
}
// 操作按钮
downloadBtn.setOnAction(event -> contentView.handleAction("download"));
renameBtn.setOnAction(event -> contentView.handleAction("rename"));
deleteBtn.setOnAction(event -> contentView.handleAction("delete"));
optimizeBtn.setOnAction(event -> contentView.handleAction("optimize"));
uploadBtn.setOnAction(event -> contentView.handleAction("upload"));
}