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


Java MenuBar類代碼示例

本文整理匯總了Java中javafx.scene.control.MenuBar的典型用法代碼示例。如果您正苦於以下問題:Java MenuBar類的具體用法?Java MenuBar怎麽用?Java MenuBar使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


MenuBar類屬於javafx.scene.control包,在下文中一共展示了MenuBar類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: showMenuBar

import javafx.scene.control.MenuBar; //導入依賴的package包/類
/**
 * show or hide the menuBar
 * 
 * @param scene
 * @param pMenuBar
 */
public void showMenuBar(Scene scene, MenuBar pMenuBar, boolean show) {
  Parent sroot = scene.getRoot();
  ObservableList<Node> rootChilds = null;
  if (sroot instanceof VBox)
    rootChilds = ((VBox) sroot).getChildren();
  if (rootChilds == null)
    throw new RuntimeException(
        "showMenuBar can not handle scene root of type "
            + sroot.getClass().getName());
  if (!show && rootChilds.contains(pMenuBar)) {
    rootChilds.remove(pMenuBar);
  } else if (show) {
    rootChilds.add(0, pMenuBar);
  }
  pMenuBar.setVisible(show);
  hideMenuButton
      .setText(show ? I18n.get(I18n.HIDE_MENU) : I18n.get(I18n.SHOW_MENU));
}
 
開發者ID:BITPlan,項目名稱:can4eve,代碼行數:25,代碼來源:JavaFXDisplay.java

示例2: start

import javafx.scene.control.MenuBar; //導入依賴的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: marathon_select

import javafx.scene.control.MenuBar; //導入依賴的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

示例4: initialize

import javafx.scene.control.MenuBar; //導入依賴的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

示例5: parseMenu

import javafx.scene.control.MenuBar; //導入依賴的package包/類
protected void parseMenu (Stage stage, MenuBar menuBar, JsonArray jsonArray) {
    Platform.runLater(() -> {
        for (int i = 0; i < jsonArray.size(); i++) {
            //get menu entry
            JsonObject entry = jsonArray.getJsonObject(i);

            //get event and title
            //String event = entry.getString("event");
            String title = entry.getString("title");

            //create new menu
            Menu menu = new Menu(title);

            //add sub menus
            this.parseSubMenus(menu, entry.getJsonArray("submenus"));

            //add menu to menu bar
            menuBar.getMenus().add(menu);
        }

        menuBar.prefWidthProperty().bind(stage.widthProperty());
    });
}
 
開發者ID:open-erp-systems,項目名稱:erp-frontend,代碼行數:24,代碼來源:DefaultMenuManager.java

示例6: PLPToolMenuBarPanel

import javafx.scene.control.MenuBar; //導入依賴的package包/類
public PLPToolMenuBarPanel(Controller controller)
{
	this.controller = controller;
	MenuBar menuBar = new MenuBar();
	
	Menu file = createFileMenu();
	Menu edit = createEditMenu();
	Menu view = createViewMenu();
	Menu project = createProjectMenu();
	Menu tools = createToolsMenu();
	Menu simulation = createSimulationMenu();
	Menu help = createHelpMenu();
	
	menuBar.getMenus().addAll(file, edit, view, project, tools, simulation, help);
	this.setCenter(menuBar);
}
 
開發者ID:dhawal9035,項目名稱:WebPLP,代碼行數:17,代碼來源:PLPToolMenuBarPanel.java

示例7: buildLicence

import javafx.scene.control.MenuBar; //導入依賴的package包/類
public static MenuBar buildLicence() {
    ClassLoader classLoader = ClassLoader.getSystemClassLoader();
    String licenseFileAsString = loadLicenseFileAsString(classLoader);

    MenuItem licenseMenuItem = new MenuItem(licenseFileAsString);

    Menu menu = new Menu("GazePlay");
    menu.getItems().add(licenseMenuItem);

    MenuBar menuBar = new MenuBar();
    menuBar.getMenus().addAll(menu);
    menuBar.setPrefHeight(40);
    menuBar.setPrefWidth(80);

    return menuBar;
}
 
開發者ID:schwabdidier,項目名稱:GazePlay,代碼行數:17,代碼來源:Utils.java

示例8: createMenuBar

import javafx.scene.control.MenuBar; //導入依賴的package包/類
/**
 * create the Menu Bar
 * 
 * @param scene
 */
public MenuBar createMenuBar(Scene scene, com.bitplan.gui.App app) {
  MenuBar lMenuBar = new MenuBar();
  for (com.bitplan.gui.Menu amenu : app.getMainMenu().getSubMenus()) {
    Menu menu = new Menu(i18n(amenu.getId()));
    lMenuBar.getMenus().add(menu);
    for (com.bitplan.gui.MenuItem amenuitem : amenu.getMenuItems()) {
      MenuItem menuItem = new MenuItem(i18n(amenuitem.getId()));
      menuItem.setOnAction(this);
      menuItem.setId(amenuitem.getId());
      menu.getItems().add(menuItem);
    }
  }

  hideMenuButton = new Button(I18n.get(I18n.HIDE_MENU));
  hideMenuButton.setOnAction(new EventHandler<ActionEvent>() {
    @Override
    public void handle(ActionEvent e) {
      showMenuBar(scene, lMenuBar, !lMenuBar.isVisible());
    }
  });
  return lMenuBar;
}
 
開發者ID:BITPlan,項目名稱:can4eve,代碼行數:28,代碼來源:JavaFXDisplay.java

示例9: start

import javafx.scene.control.MenuBar; //導入依賴的package包/類
@Override
public void start(Stage primaryStage) throws NotYetSupportException, GargoyleConnectionFailException, InstantiationException, IllegalAccessException, ClassNotFoundException {
	primaryStage.setTitle("Database Exam");

	CommonsSqllPan sqlPane = CommonsSqllPan.getSqlPane();
	sqlPane.getStylesheets().add(SkinManager.getInstance().getSkin());
	BorderPane root = new BorderPane(sqlPane);
	Menu menu = new Menu("Exam");
	MenuItem e = new MenuItem("exam");
	e.setOnAction(System.out::println);
	e.setAccelerator(new KeyCodeCombination(KeyCode.E, KeyCombination.CONTROL_DOWN));
	menu.getItems().add(e);
	root.setTop(new MenuBar(menu));

	primaryStage.setScene(new Scene(root, 1100, 700));

	primaryStage.show();

	// Application.setUserAgentStylesheet(Application.STYLESHEET_MODENA);

	// DockPane.initializeDefaultUserAgentStylesheet();

}
 
開發者ID:callakrsos,項目名稱:Gargoyle,代碼行數:24,代碼來源:SqlTabPanExample.java

示例10: MnemonicsScene

import javafx.scene.control.MenuBar; //導入依賴的package包/類
public MnemonicsScene() {
    super(box, 600, 400);
    Utils.addBrowser(this);

    final MenuBar bar = new MenuBar();
    generateMenus(bar.getMenus(), 2, 2, 0);

    CheckBox check = new CheckBox("setMnemonicParse()");
    check.setSelected(true);
    check.setId(CHECK_MENU_PARSE_ID);
    check.selectedProperty().addListener(new ChangeListener<Boolean>() {
        public void changed(ObservableValue<? extends Boolean> ov, Boolean t, Boolean t1) {
            setMnemocicParse((ObservableList)bar.getMenus(), t1);
        }
    });

    box.getChildren().addAll(bar, check);
}
 
開發者ID:teamfx,項目名稱:openjfx-8u-dev-tests,代碼行數:19,代碼來源:MenuMnemonicsApp.java

示例11: dnd

import javafx.scene.control.MenuBar; //導入依賴的package包/類
protected void dnd() throws InterruptedException {
    sceneSource.mouse().click(1, new Point(0, 0));
    Wrap from = Lookups.byID(sceneSource, ID_DRAG_SOURCE, Node.class);
    Wrap to = Lookups.byID(sceneTarget, ID_DRAG_TARGET, Node.class);
    Point fromPoint = from.getClickPoint();
    Point toPoint = to.getClickPoint();
    final Object fromControl = from.getControl();
    if (fromControl instanceof MenuBar || fromControl instanceof ToolBar
            || fromControl instanceof ScrollPane || fromControl instanceof Pagination) {
        fromPoint = new Point(2, 2);
    }
    if (fromControl instanceof TitledPane) {
        fromPoint = new Point(5, 30);
    }
    final Object toControl = to.getControl();
    if (toControl instanceof MenuBar || toControl instanceof ToolBar
            || toControl instanceof ScrollPane || toControl instanceof Pagination) {
        toPoint = new Point(2, 2);
    }
    if (toControl instanceof TitledPane) {
        toPoint = new Point(30, 30);
    }
    dnd(from, fromPoint, to, toPoint);
}
 
開發者ID:teamfx,項目名稱:openjfx-8u-dev-tests,代碼行數:25,代碼來源:DragDropWithControlsBase.java

示例12: setUpClass

import javafx.scene.control.MenuBar; //導入依賴的package包/類
@BeforeClass
public static void setUpClass() throws Exception {
    MenuApp.main(null);
    scene = Root.ROOT.lookup().wrap();
    sceneAsParent = scene.as(Parent.class, Node.class);
    menuBar = (MenuBarWrap) sceneAsParent.lookup(MenuBar.class).wrap();
    menu = (MenuWrap<? extends Menu>) menuBar.as(Parent.class, Menu.class).lookup().wrap();
    menuAsParent = menu.as(Parent.class, MenuItem.class);
    container = menuBar;
    object = menu;
    contentPane = sceneAsParent.lookup(new ByID<Node>(MenuApp.TEST_PANE_ID)).wrap();
    clearBtn = sceneAsParent.lookup(new ByText(MenuApp.CLEAR_BTN_ID)).wrap();
    resetBtn = sceneAsParent.lookup(new ByText(MenuApp.RESET_BTN_ID)).wrap();
    addPosBtn = sceneAsParent.lookup(new ByText(MenuApp.ADD_SINGLE_AT_POS_BTN_ID)).wrap();
    removePosBtn = sceneAsParent.lookup(new ByText(MenuApp.REMOVE_SINGLE_AT_POS_BTN_ID)).wrap();
    check = (Wrap<? extends Label>) sceneAsParent.lookup(new ByID(MenuApp.LAST_SELECTED_ID)).wrap();
    hidden = sceneAsParent.lookup(CheckBox.class, new ByID<CheckBox>(MenuApp.SHOWN_CHECK_ID)).wrap();
    hiding = sceneAsParent.lookup(CheckBox.class, new ByID<CheckBox>(MenuApp.SHOWING_CHECK_ID)).wrap();
}
 
開發者ID:teamfx,項目名稱:openjfx-8u-dev-tests,代碼行數:20,代碼來源:MenuTest.java

示例13: setUpClass

import javafx.scene.control.MenuBar; //導入依賴的package包/類
@BeforeClass
public static void setUpClass() throws Exception {
    MenuItemApp.main(null);
    scene = Root.ROOT.lookup().wrap();
    sceneAsParent = scene.as(Parent.class, Node.class);
    menuBar = sceneAsParent.lookup(MenuBar.class).wrap();
    menuBarAsParent = menuBar.as(Parent.class, Menu.class);
    menuBarLookup = menuBarAsParent.lookup(Menu.class, new LookupCriteria<Menu>() {
        public boolean check(Menu control) {
            return control.getParentMenu() == null;
        }
    });
    menuAsMenuOwner = menuBar.as(MenuOwner.class, Menu.class);
    contentPane = sceneAsParent.lookup(new ByID<Node>(MenuItemApp.TEST_PANE_ID)).wrap();
    clearLastSelectedBtn = sceneAsParent.lookup(new ByText(MenuItemApp.LAST_PRESSED_CLEAR_BTN_ID)).wrap();
    clearLastEventBtn = sceneAsParent.lookup(new ByText(MenuItemApp.LAST_EVENT_CLEAR_BTN_ID)).wrap();
    disableBtn = sceneAsParent.lookup(CheckBox.class, new ByText(MenuItemApp.DISABLE_CB_ID)).wrap();
    eventBtn = sceneAsParent.lookup(CheckBox.class, new ByText(MenuItemApp.EVENT_CB_ID)).wrap();
    hideBtn = sceneAsParent.lookup(CheckBox.class, new ByText(MenuItemApp.HIDE_CB_ID)).wrap();
    lastSelected = sceneAsParent.lookup(new ByID(MenuItemApp.LAST_PRESSED_ID)).wrap();
    lastEvent = sceneAsParent.lookup(new ByID(MenuItemApp.LAST_EVENT_ID)).wrap();
}
 
開發者ID:teamfx,項目名稱:openjfx-8u-dev-tests,代碼行數:23,代碼來源:MenuItemTest.java

示例14: impl_drawNode

import javafx.scene.control.MenuBar; //導入依賴的package包/類
@Override
public Node impl_drawNode() throws IOException {
    Menu uplevelNode = null;
    FXMLLoader fxmlLoader = new FXMLLoader(resource);
    try {
            uplevelNode = (Menu)fxmlLoader.load();
    } catch (Exception e) {
        System.out.println("message: " + e.getMessage());
        reportGetterFailure("message: " + e.getMessage());
        ParseTraceElement ptes[] = fxmlLoader.impl_getParseTrace();
        for (ParseTraceElement pte: ptes) {
            // see rt-19329
            System.out.println("trace element: " + pte);
        }

    }
    MenuBar mb = new MenuBar();
    mb.getMenus().add(uplevelNode);
    // debug: uplevelNode.getItems().add(new MenuItem("open!!"));
    return mb;
}
 
開發者ID:teamfx,項目名稱:openjfx-8u-dev-tests,代碼行數:22,代碼來源:staticPropertyLoadApp.java

示例15: buildMenuBarWithMenus

import javafx.scene.control.MenuBar; //導入依賴的package包/類
public MenuBar buildMenuBarWithMenus(HTMLEditor editor, final ReadOnlyDoubleProperty menuWidthProperty, String STYLE_CSS){
    MenuBar menuBar = new MenuBar();
    menuBar.setStyle(STYLE_CSS);
    
    
    // Add File menu to menu bar
    menuBar.getMenus().add(new FileMenuBuilder().getProduct(editor));
    //Add Edit menu to menu bar
    menuBar.getMenus().add(new EditMenuBuilder().getProduct(editor)) ;
    //Add Insert menu to menu bar
    menuBar.getMenus().add(new InsertMenuBuilder().getProduct(editor));
    //Add Indent menu to menu bar
    menuBar.getMenus().add(new IndentMenuBuilder().getProduct(editor));
    // Add View menu to menu bar
    menuBar.getMenus().add(new ViewMenuBuilder().getProduct(editor));
    
    
    // bind width of menu bar to width of associated stage
    menuBar.prefWidthProperty().bind(menuWidthProperty);
    return menuBar;
}
 
開發者ID:Hydral1k,項目名稱:HTMLEditor,代碼行數:22,代碼來源:MenuBuilder.java


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