当前位置: 首页>>代码示例>>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;未经允许,请勿转载。