Java Code Examples for javafx.scene.control.MenuBar

The following are top voted examples for showing how to use javafx.scene.control.MenuBar. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: can4eve   File: JavaFXDisplay.java   Source Code and License 10 votes vote down vote up
/**
 * 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));
}
 
Example 2
Project: Vokabeltrainer   File: Main.java   Source Code and License 7 votes vote down vote up
@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();
	}
 
Example 3
Project: marathonv5   File: JavaFXMenuBarElement.java   Source Code and License 6 votes vote down vote up
@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;
}
 
Example 4
Project: atbash-octopus   File: ApplicationMenu.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 5
Project: erp-frontend   File: DefaultMenuManager.java   Source Code and License 6 votes vote down vote up
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());
    });
}
 
Example 6
Project: WebPLP   File: PLPToolMenuBarPanel.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 7
Project: GazePlay   File: Utils.java   Source Code and License 6 votes vote down vote up
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;
}
 
Example 8
Project: can4eve   File: JavaFXDisplay.java   Source Code and License 6 votes vote down vote up
/**
 * 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;
}
 
Example 9
Project: Gargoyle   File: SqlTabPanExample.java   Source Code and License 6 votes vote down vote up
@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();

}
 
Example 10
Project: openjfx-8u-dev-tests   File: MenuMnemonicsApp.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 11
Project: openjfx-8u-dev-tests   File: DragDropWithControlsBase.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 12
Project: openjfx-8u-dev-tests   File: MenuTest.java   Source Code and License 6 votes vote down vote up
@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();
}
 
Example 13
Project: openjfx-8u-dev-tests   File: MenuItemTest.java   Source Code and License 6 votes vote down vote up
@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();
}
 
Example 14
Project: openjfx-8u-dev-tests   File: staticPropertyLoadApp.java   Source Code and License 6 votes vote down vote up
@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;
}
 
Example 15
Project: HTMLEditor   File: MenuBuilder.java   Source Code and License 6 votes vote down vote up
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;
}
 
Example 16
Project: mars-sim   File: AboutMenu.java   Source Code and License 6 votes vote down vote up
@Override public void start(Stage primaryStage) throws Exception {
  primaryStage.setScene(new Scene(new StackPane()));
  primaryStage.show();

  MenuToolkit tk = MenuToolkit.toolkit();

  AboutStageBuilder aboutStageBuilder = AboutStageBuilder.start("About MyApp")
      .withAppName("MyApp").withCloseOnFocusLoss().withHtml("<i>Some descriptive text</i>")
      .withVersionString("Version 1.0b").withCopyright("Copyright \u00A9 " + Calendar
          .getInstance().get(Calendar.YEAR));


  try {
    IcnsParser parser = IcnsParser.forFile(AboutStageBuilder.DEFAULT_APP_ICON);
    aboutStageBuilder = aboutStageBuilder.withImage(new Image(parser.getIconStream(IcnsType.ic08)));
  } catch (IOException e) {
    // Too bad, cannot load dummy image
  }

  Menu applicationMenu = tk.createDefaultApplicationMenu("MyApp", aboutStageBuilder.build());

  MenuBar bar = new MenuBar();
  bar.getMenus().add(applicationMenu);
  tk.setMenuBar(bar);
}
 
Example 17
Project: NSMenuFX   File: AboutMenu.java   Source Code and License 6 votes vote down vote up
@Override public void start(Stage primaryStage) throws Exception {
  primaryStage.setScene(new Scene(new StackPane()));
  primaryStage.show();

  MenuToolkit tk = MenuToolkit.toolkit();

  AboutStageBuilder aboutStageBuilder = AboutStageBuilder.start("About MyApp")
      .withAppName("MyApp").withCloseOnFocusLoss().withHtml("<i>Some descriptive text</i>")
      .withVersionString("Version 1.0b").withCopyright("Copyright \u00A9 " + Calendar
          .getInstance().get(Calendar.YEAR));


  try {
    IcnsParser parser = IcnsParser.forFile(AboutStageBuilder.DEFAULT_APP_ICON);
    aboutStageBuilder = aboutStageBuilder.withImage(new Image(parser.getIconStream(IcnsType.ic08)));
  } catch (IOException e) {
    // Too bad, cannot load dummy image
  }

  Menu applicationMenu = tk.createDefaultApplicationMenu("MyApp", aboutStageBuilder.build());

  MenuBar bar = new MenuBar();
  bar.getMenus().add(applicationMenu);
  tk.setMenuBar(bar);
}
 
Example 18
Project: NSMenuFX   File: JavaFXDefault.java   Source Code and License 6 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception {
	MenuToolkit tk = MenuToolkit.toolkit(Locale.getDefault());
	tk.setApplicationMenu(tk.createDefaultApplicationMenu("test"));

	MenuBar menuBar = new MenuBar();
	menuBar.useSystemMenuBarProperty().set(true);

	Menu menu = new Menu("java");
	MenuItem item = new MenuItem("Test");

	Menu help = new Menu("Help");
	menu.getItems().add(item);
	menuBar.getMenus().addAll(menu, help);

	primaryStage.setScene(new Scene(new Pane(menuBar)));
	primaryStage.setTitle("Test");
	primaryStage.show();
}
 
Example 19
Project: Equi   File: MainPanel.java   Source Code and License 6 votes vote down vote up
public MainPanel(Stage owner) {
    GraphListPanel panel = new GraphListPanel();
    panel.setGraphProcessor(graph -> processSelectedGraph(graph, owner));

    MenuBar menuBar = new MenuBar();
    Menu fileMenu = new Menu("_File");
    fileMenu.getItems().addAll(
            panel.createMenuItemOpen(owner),
            new SeparatorMenuItem(),
            createMenuItemExit()
    );

    menuBar.getMenus().addAll(fileMenu);

    setTop(menuBar);
    setCenter(panel);
}
 
Example 20
Project: VOOGASalad   File: SpriteMovement.java   Source Code and License 6 votes vote down vote up
private Pane makePopUpPane(String movementType, Stage stage){
	VBox smallPane=new VBox();
	smallPane.setStyle("-fx-background-color: BLACK");
	Label movementLabel=new Label(" Pick the Key for the Movement");
	movementLabel.setPrefSize(290, 70);
	movementLabel.setTextAlignment(TextAlignment.CENTER);
	//movementLabel.relocate(0, 0);
	movementLabel.getStylesheets().add("./com/print_stack_trace/voogasalad/controller/guiResources/SpritePane.css");
	movementLabel.getStyleClass().add("keylabel1");
	MenuBar moveMentFunction=new MenuBar();
	//moveMentFunction.relocate(0, 70);
	moveMentFunction.setPrefWidth(290);
	moveMentFunction.setPrefHeight(75);
	moveMentFunction.getStylesheets().add("./com/print_stack_trace/voogasalad/controller/guiResources/SpritePane.css");
	Menu myMovement=new Menu("Key Options");
	addKeyMenus(movementType, myMovement, stage);
	moveMentFunction.getMenus().addAll(myMovement);
	smallPane.getChildren().addAll(movementLabel, moveMentFunction);
	return smallPane;
}
 
Example 21
Project: VOOGASalad   File: MessagePopUp.java   Source Code and License 6 votes vote down vote up
public String showDropDownDialog(String message, String[] options){
	MenuBar bar=new MenuBar();
	bar.relocate(0, height/2);
	bar.setPrefSize(width/1.3, height/5);
	Menu menuName=new Menu("Please Pick One");
	for (int i=0; i<options.length; i++){
		MenuItem item=new MenuItem(options[i]);
		item.setOnAction(e->{
			dropDownString=item.getText();
			close();
		});
		menuName.getItems().add(item);
	}
	bar.getMenus().add(menuName);
	add(bar);
	makeMessage(message);
	showStage();
	return dropDownString;
}
 
Example 22
Project: LJGM   File: LJGM.java   Source Code and License 6 votes vote down vote up
/**
 * Creates the menu bar.
 * 
 * @return the menu bar
 */
private MenuBar createMenuBar() {
	MenuBar menuBar = new MenuBar();
	Menu file = new Menu("File");

	Menu about = new Menu("About");
	MenuItem aboutProject = new MenuItem("About LJGM");
	aboutProject.setOnAction(new EventHandler<ActionEvent>() {

		@Override
		public void handle(ActionEvent e) {
			// show about dialog
		}
	});
	about.getItems().add(aboutProject);

	menuBar.getMenus().addAll(file, about);

	return menuBar;
}
 
Example 23
Project: lawless-legends   File: UIAction.java   Source Code and License 6 votes vote down vote up
public static MenuBar buildMenu() {
    MenuBar menu = new MenuBar();
    Menu currentMenu = null;
    for (final MAIN_ACTIONS action : UIAction.MAIN_ACTIONS.values()) {
        if (action.name().startsWith("_")) {
            if (currentMenu != null) {
                menu.getMenus().add(currentMenu);
            }
            currentMenu = new Menu(action.name().replace("_", ""));
        } else {
            MenuItem item = new MenuItem(action.name().replaceAll("_", " "));
            item.setOnAction((ActionEvent t) -> {
                try {
                    actionPerformed(action);
                } catch (IOException ex) {
                    Logger.getLogger(Application.class.getName()).log(Level.SEVERE, null, ex);
                }
            });
            currentMenu.getItems().add(item);
        }
    }
    menu.getMenus().add(currentMenu);
    menu.setMinWidth(1.0);
    return menu;
}
 
Example 24
Project: Suji   File: Main.java   Source Code and License 5 votes vote down vote up
private void buildMenuBar() {
	//file menu, creating the main tabs
	Menu fileMenu = getFileMenu();
	Menu ogsMenu = getOGSMenu();
	Menu settingsMenu = getSettingsMenu();

	//main menu bar
	menuBar = new MenuBar();
	menuBar.getMenus().addAll(fileMenu, ogsMenu, settingsMenu);
}
 
Example 25
Project: marathonv5   File: RFXMenuItem.java   Source Code and License 5 votes vote down vote up
private boolean isMenuBar(Node ownerNode) {
    Node parent = ownerNode;
    while (parent != null) {
        if (parent instanceof MenuBar) {
            this.menuBar = (MenuBar) parent;
            return true;
        }
        parent = parent.getParent();
    }
    return false;
}
 
Example 26
Project: GameAuthoringEnvironment   File: AuthoringView.java   Source Code and License 5 votes vote down vote up
private MenuBar createMenuBar () {
    MenuBar menuBar = new MenuBar();
    Menu fileMenu = new Menu(myLabel.getString("File"));
    MenuItem goHome = createMenuItems(myLabel.getString("GoHome"), e -> goHome());
    MenuItem saveItem = createMenuItems(myLabel.getString("Save"), e -> saveToXML());
    MenuItem loadItem = createMenuItems(myLabel.getString("Load"), e -> loadGame());
    MenuItem launchItem = createMenuItems(myLabel.getString("Launch"), e -> launchGame());
    fileMenu.getItems().add(goHome);
    fileMenu.getItems().add(saveItem);
    fileMenu.getItems().add(loadItem);
    fileMenu.getItems().add(launchItem);
    menuBar.getMenus().add(fileMenu);
    return menuBar;
}
 
Example 27
Project: GameAuthoringEnvironment   File: GameLibraryView.java   Source Code and License 5 votes vote down vote up
private void createMenuBar () {
    MenuBar menuBar = new MenuBar();
    Menu menu = new Menu(myLang.getString("File"));
    myHomeItem = new MenuItem(myLang.getString("GoHome"));
    myHomeItem.setOnAction(e -> new MainUserInterface().init(myStage));

    menu.getItems().add(myHomeItem);
    menuBar.getMenus().add(menu);
    myLayout.setTop(menuBar);
}
 
Example 28
Project: OftenPorter   File: FXUIProvider.java   Source Code and License 5 votes vote down vote up
private void search(UIPlatform uiPlatform, Parent parent)
{
    ObservableList<Node> list = parent.getChildrenUnmodifiable();
    if (list.size() == 0)
    {
        return;
    }
    final String idPrefix = getPrefix().idPrefix;
    final String pathPrefix = getPrefix().pathPrefix;
    IdDeal idDeal = uiPlatform.getIdDeal();
    BinderFactory factory = uiPlatform.getBinderFactory();
    for (int i = 0; i < list.size(); i++)
    {
        Node node = list.get(i);
        UiId id = UiId.newInstance(node.getId(), idPrefix);
        if (id != null)
        {
            IdDeal.Result result = idDeal.dealId(id, pathPrefix);
            if (result != null)
            {
                hashMap.put(id, factory.getBinder(node));
            }
        }
        if (node instanceof Parent)
        {
            search(uiPlatform, (Parent) node);
        }
        if (node instanceof MenuBar)
        {
            search(uiPlatform, (MenuBar) node);
        }
    }
}
 
Example 29
Project: OftenPorter   File: FXUIProvider.java   Source Code and License 5 votes vote down vote up
/**
 * 菜单栏的搜索
 *
 * @param uiPlatform
 * @param menuBar
 */
private void search(UIPlatform uiPlatform, MenuBar menuBar)
{
    ObservableList<Menu> list = menuBar.getMenus();
    if (list.size() == 0)
    {
        return;
    }
    final String idPrefix = getPrefix().idPrefix;
    final String pathPrefix = getPrefix().pathPrefix;
    IdDeal idDeal = uiPlatform.getIdDeal();
    BinderFactory factory = uiPlatform.getBinderFactory();
    for (int i = 0; i < list.size(); i++)
    {
        Menu menu = list.get(i);
        UiId id = UiId.newInstance(menu.getId(), idPrefix);
        if (id != null)
        {
            IdDeal.Result result = idDeal.dealId(id, pathPrefix);
            if (result != null)
            {
                hashMap.put(id, factory.getBinder(menu));
            }
        }
        search(uiPlatform, menu);
    }
}
 
Example 30
Project: CalendarFX   File: GoogleCalendarAppViewSkin.java   Source Code and License 5 votes vote down vote up
private MenuBar createMenuBar(GoogleAutoRefreshThread autoRefreshThread) {
    MenuItem logoutItem = new MenuItem("Logout");
    logoutItem.setOnAction(evt -> logout());

    MenuItem exitItem = new MenuItem("Exit");
    exitItem.setAccelerator(KeyCombination.keyCombination("shortcut+q"));
    exitItem.setOnAction(evt -> Platform.exit());

    Menu fileMenu = new Menu("File");
    fileMenu.getItems().add(logoutItem);
    fileMenu.getItems().add(exitItem);

    MenuItem refreshItem = new MenuItem("Refresh");
    refreshItem.setOnAction(evt -> autoRefreshThread.restart());
    refreshItem.setAccelerator(KeyCombination.keyCombination("F5"));

    ToggleGroup intervalGroup = new ToggleGroup();
    Menu autoRefreshItem = new Menu("Auto Refresh");

    for (GoogleAutoRefreshThread.RefreshInterval interval : GoogleAutoRefreshThread.RefreshInterval.values()) {
        RadioMenuItem intervalItem = new RadioMenuItem(interval.getName());
        intervalItem.setOnAction(evt -> autoRefreshThread.setDelay(interval.getTime()));
        intervalItem.setToggleGroup(intervalGroup);
        intervalItem.setSelected(interval.getTime() == autoRefreshThread.getDelay());
        autoRefreshItem.getItems().add(intervalItem);
    }

    Menu viewMenu = new Menu("View");
    viewMenu.getItems().addAll(refreshItem, autoRefreshItem);

    MenuBar menuBar = new MenuBar();
    menuBar.setUseSystemMenuBar(true);
    menuBar.getMenus().add(fileMenu);
    menuBar.getMenus().add(viewMenu);

    return menuBar;
}
 
Example 31
Project: can4eve   File: TestAppGUI.java   Source Code and License 5 votes vote down vote up
@Test
public void testTabIcons() throws Exception {
  JavaFXDisplay display = super.getDisplay();
  VBox vbox = new VBox();
  display.setRoot(vbox);
  SampleApp sampleApp = new SampleApp("menus", vbox);
  sampleApp.show();
  sampleApp.waitOpen();
  display.setStage(sampleApp.getStage());
  Platform.runLater(() -> {
    MenuBar menuBar = display.createMenuBar(sampleApp.getScene(),
        display.getApp());
    display.setMenuBar(menuBar);
    display.showMenuBar(sampleApp.getScene(), menuBar, true);
    display.setUpStatusBar();
  });
  XYTabPane xyTabPane = display.getXyTabPane();
  Platform.runLater(() -> {
    display.setupXyTabPane();
    display.setupDashBoard();
  });
  // xyTabPane.prefHeightProperty().bind(display.getStage().heightProperty());
  display.getStage().heightProperty()
      .addListener(new ChangeListener<Number>() {

        @Override
        public void changed(ObservableValue<? extends Number> observable,
            Number oldValue, Number newValue) {
          if (xyTabPane != null)
            System.out.println("oldh: " + oldValue.intValue() + " newh: "
                + newValue.intValue() + " xyh:" + xyTabPane.getPrefHeight()
                + " vth:" + xyTabPane.getvTabPane().getPrefHeight());
        }
      });
  Thread.sleep(SHOW_TIME);
  sampleApp.close();
}
 
Example 32
Project: voogasalad-ltub   File: LevelManager.java   Source Code and License 5 votes vote down vote up
/**
 * show the Level MenuItem to the player
 * The player can choose a level to start a game or choose a random game
 */
public void show(){
	//Stage primaryStage = new Stage();
	primaryStage.setTitle(TITLE);
	Group root = new Group();

	Menu level = initLevelMenu();
	Menu setting = initSettingMenu();
	Menu help = initHelpMenu();
	menuBar = new MenuBar(level, setting, help);
	root.getChildren().add(menuBar);
	
	AnimationImage im = new AnimationImage();		
	
	Scene scene = new Scene(root);
	Image image = new Image(getClass().getClassLoader().getResourceAsStream(myResources.getString("levelChoiceImagePath")));
	scene.setFill(new ImagePattern(image));		
	scene.getStylesheets().setAll(CSS_LOCATION);
	
	HBox hBox = new HBox();
	hBox.getChildren().add(im.getImageView(SEED));
	hBox.setLayoutX(300);
	hBox.setLayoutY(200);
	root.getChildren().add(hBox);

	Button starting = createButton();		
	root.getChildren().add(starting);
	
	primaryStage.setScene(scene);
	primaryStage.setFullScreen(true);
	primaryStage.setFullScreenExitHint("");
	primaryStage.setFullScreenExitKeyCombination(null);
	primaryStage.show();
}
 
Example 33
Project: SkyHussars   File: EditorView.java   Source Code and License 5 votes vote down vote up
public MenuBar menubar(PlaneEd planeEd) {
    MenuBar menuBar = new MenuBar();
    Menu fileMenu = new Menu("File");
    ObservableList<MenuItem> mis = fileMenu.getItems();
    mis.add(loadMenu(planeEd));
    mis.add(saveMenu(planeEd));
    mis.add(saveAsMenu(planeEd));
    menuBar.getMenus().add(fileMenu);
    return menuBar;
}
 
Example 34
Project: Gargoyle   File: DesignerFx.java   Source Code and License 5 votes vote down vote up
private MenuBar createFxMenuBar() {
	MenuBar menuBar = new MenuBar();
	Menu menu = new Menu("Language");

	ToggleGroup group = new ToggleGroup();

	LanguageVersion[] languageVersions = getSupportedLanguageVersions();
	for (int i = 0; i < languageVersions.length; i++) {
		LanguageVersion languageVersion = languageVersions[i];

		//			JRadioButtonMenuItem button = new JRadioButtonMenuItem(languageVersion.getShortName());
		RadioMenuItem button = new RadioMenuItem(languageVersion.getShortName());
		button.setToggleGroup(group);
		languageVersionMenuItems[i] = button;
		//			group.add(button);
		menu.getItems().add(button);
	}
	//		languageVersionMenuItems[DEFAULT_LANGUAGE_VERSION_SELECTION_INDEX].setSelected(true);
	languageVersionMenuItems[getDefaultLanguageVersionSelectionIndex()].setSelected(true);

	menuBar.getMenus().add(menu);

	Menu actionsMenu = new Menu("Actions");
	MenuItem copyXMLItem = new MenuItem("Copy xml to clipboard");
	copyXMLItem.setOnAction(e -> copyXmlToClipboard());

	actionsMenu.getItems().add(copyXMLItem);
	MenuItem createRuleXMLItem = new MenuItem("Create rule XML");
	createRuleXMLItem.setOnAction(e -> createRuleXML());
	actionsMenu.getItems().add(createRuleXMLItem);
	menuBar.getMenus().add(actionsMenu);

	return menuBar;

}
 
Example 35
Project: gralog   File: MainMenu.java   Source Code and License 5 votes vote down vote up
MainMenu(Handlers handlers) {
    this.handlers = handlers;

    menu = new MenuBar();
    menu.getMenus().addAll(
        createFileMenu(),
        createEditMenu(),
        createAlgorithmMenu(),
        createHelpMenu());

    updateStructures();
    updateGenerators();
}
 
Example 36
Project: zunozap   File: ZunoZapWebView.java   Source Code and License 5 votes vote down vote up
@Override
public void start(Stage stage, Scene scene, StackPane root, BorderPane border) throws Exception {
    OptionMenu.init();
    tb = new TabPane();
    menuBar = new MenuBar();
    bmread = new Reader(menuBook);
    bmread.refresh();

    mkDirs(home, saveDir, temp, cssDir);

    stage.getIcons().add(new Image(ZunoZap.class.getClassLoader().getResourceAsStream("zunozaplogo.gif")));
    tb.setPrefSize(1365, 768);
    tb.setSide(Side.TOP);

    /// Setup tabs
    Tab newtab = new Tab(" + ");
    newtab.setClosable(false);
    tb.getTabs().add(newtab);
    createTab(true);

    tb.getSelectionModel().selectedItemProperty().addListener((a,b,c) -> { if (c == newtab) createTab(false); });

    border.setCenter(tb);
    border.setTop(menuBar);
    border.autosize();

    WebView dummy = new WebView();
    setUserAgent(dummy.getEngine());
    regMenuItems(bmread, menuFile, menuBook, aboutPageHTML("Java WebView", dummy.getEngine().getUserAgent(), "ZunoZap/zunozap/master/LICENCE", "LGPLv3", "N/A"), tb, Engine.WEBKIT);
    menuBar.getMenus().addAll(menuFile, menuBook);
    sm = new StyleManager(cssDir, scene);
    scene.getStylesheets().add(ZunoAPI.stylesheet.toURI().toURL().toExternalForm());

    p.loadPlugins();
    if (allowPluginEvents()) for (PluginBase pl : p.plugins) pl.onLoad(stage, scene, tb);
}
 
Example 37
Project: myWMS   File: MyWMS.java   Source Code and License 5 votes vote down vote up
public VBox makeMenuBar() {
	  Menu fileMenu = new Menu("_File");

	  fileMenu.getItems().add(createZoomMenus());
	  fileMenu.getItems().add(new SeparatorMenuItem());

	  MenuItem mi = new MenuItem("Garbage Collect");
	  mi.setOnAction((e) -> System.gc());
	  fileMenu.getItems().add(mi);

	  fileMenu.getItems().add(new SeparatorMenuItem());

	  CheckMenuItem hideToolBar = new CheckMenuItem("Hide toolbar");

	  MenuItem mi2 = new MenuItem("Exit");
	  mi2.setOnAction((e) -> {
			Platform.exit();
			System.exit(0);
	  });
	  fileMenu.getItems().addAll(hideToolBar, mi2);

	  MenuBar menuBar = new MenuBar();
	  menuBar.setUseSystemMenuBar(true);
		menuBar.getMenus().addAll(fileMenu);

    List<MyWMSMainMenuPlugin> runners = getActions();
    for (MyWMSMainMenuPlugin m : runners) {
      runnerActions.put(m.getPath(), m);
    }

    MenuUtils.buildMenu(context, menuBar, runners,  applicationPane.getOnAddNode());

//	  ToolBar tool = makeToolBar(toolBarActions);
//	  tool.managedProperty().bind(tool.visibleProperty());
//	  tool.visibleProperty().bind(hideToolBar.selectedProperty().not());

	  VBox box = new VBox(menuBar);

    return box;
	}
 
Example 38
Project: JGitFX   File: TextEditorWithGit.java   Source Code and License 5 votes vote down vote up
@Override
public void start(Stage primaryStage) {
    stage = primaryStage;

    /*
        BorderPane {
            Top {
                MenuBar {
                    File {
                        Exit - closes program
                    }
                    Git {
                        // code yet to be implemented
                    }
                }
            }
            Center {
                TextArea - the plaintext Text editor
            }
        }
    */
    area = new TextArea();

    // set up MenuBar, its Menus, and
    Menu fileMenu = initFileMenu();
    Menu gitMenu = initGitMenu(primaryStage);
    MenuBar menuBar = new MenuBar(fileMenu, gitMenu);

    root.setTop(menuBar);
    root.setCenter(area);
    root.setBottom(scrollPane);

    Scene scene = new Scene(root, 800, 800);
    primaryStage.setScene(scene);
    primaryStage.show();
}
 
Example 39
Project: MineIDE-UI   File: GuiActionBar.java   Source Code and License 5 votes vote down vote up
public static void init(Scene scene)
{
    MenuBar menuBar = new MenuBar();
    SpecificClasses.initSubClasses();

    menuBar.getMenus().addAll(createFileMenu(), createEditMenu(), createForgeMenu(), createOptionMenu(),
            createMinecraftMenu(), createRunMenu(), createHelpMenu());
    ((VBox) scene.getRoot()).getChildren().addAll(menuBar);
}
 
Example 40
Project: openjfx-8u-dev-tests   File: MenuBarTest.java   Source Code and License 5 votes vote down vote up
@BeforeClass
public static void setUpClass() throws Exception {
    MenuBarApp.main(null);
    scene = Root.ROOT.lookup().wrap();
    sceneAsParent = scene.as(Parent.class, Node.class);
    menuBar = sceneAsParent.lookup(MenuBar.class).wrap();
    container = menuBar;
    object = menuBar;
    menuAsStringMenuOwner = menuBar.as(StringMenuOwner.class, Menu.class);
    menuAsParent = menuBar.as(Parent.class, Menu.class);
    contentPane = sceneAsParent.lookup(new ByID<Node>(MenuBarApp.TEST_PANE_ID)).wrap();
    clearBtn = sceneAsParent.lookup(new ByText(MenuBarApp.CLEAR_BTN_ID)).wrap();
    resetBtn = sceneAsParent.lookup(new ByText(MenuBarApp.RESET_BTN_ID)).wrap();
}