當前位置: 首頁>>代碼示例>>Java>>正文


Java Menu類代碼示例

本文整理匯總了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;
}
 
開發者ID:GoSuji,項目名稱:Suji,代碼行數:17,代碼來源:Main.java

示例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();
	}
 
開發者ID:dunkelziffer,項目名稱:Vokabeltrainer,代碼行數:36,代碼來源:Main.java

示例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;
}
 
開發者ID:ScreachFr,項目名稱:titanium,代碼行數:25,代碼來源:MainPane.java

示例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();
}
 
開發者ID:ProgrammingLife2017,項目名稱:hygene,代碼行數:21,代碼來源:MenuControllerTest.java

示例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;
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:23,代碼來源:JavaFXMenuBarElement.java

示例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;
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:18,代碼來源:RFXMenuItem.java

示例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));
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:19,代碼來源:RFXMenuItemTest.java

示例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));
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:20,代碼來源:RFXMenuItemTest.java

示例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));
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:22,代碼來源:RFXMenuItemTest.java

示例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));
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:21,代碼來源:RFXMenuItemTest.java

示例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));
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:24,代碼來源:RFXMenuItemTest.java

示例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);
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:27,代碼來源:SpatialTreeNode.java

示例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);
}
 
開發者ID:Leviathan-Studio,項目名稱:MineIDE,代碼行數:20,代碼來源:MenuManagement.java

示例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);
}
 
開發者ID:atbashEE,項目名稱:atbash-octopus,代碼行數:23,代碼來源:ApplicationMenu.java

示例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"));
}
 
開發者ID:cmlanche,項目名稱:javafx-qiniu-tinypng-client,代碼行數:37,代碼來源:MainView.java


注:本文中的javafx.scene.control.Menu類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。