List of usage examples for javafx.scene.control Menu show
public void show()
From source file:Main.java
@Override public void start(final Stage primaryStage) { primaryStage.setTitle("title"); Group root = new Group(); Scene scene = new Scene(root, 400, 300, Color.WHITE); MenuBar menuBar = new MenuBar(); menuBar.prefWidthProperty().bind(primaryStage.widthProperty()); Menu menu = new Menu("File"); menu.show(); MenuItem newItem = new MenuItem("New", null); newItem.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent event) { System.out.println("Action"); }/*from w w w .j av a 2 s . com*/ }); menu.getItems().add(newItem); menu.getItems().add(new SeparatorMenuItem()); menuBar.getMenus().add(menu); root.getChildren().add(menuBar); primaryStage.setScene(scene); primaryStage.show(); }
From source file:com.neuronrobotics.bowlerstudio.MainController.java
private void setToLoggedIn(final String name) { // new Exception().printStackTrace(); FxTimer.runLater(Duration.ofMillis(100), () -> { logoutGithub.disableProperty().set(false); logoutGithub.setText("Log out " + name); new Thread() { public void run() { GitHub github = ScriptingEngine.getGithub(); while (github == null) { github = ScriptingEngine.getGithub(); ThreadUtil.wait(20); }// w w w. ja v a2 s . com try { GHMyself myself = github.getMyself(); PagedIterable<GHGist> gists = myself.listGists(); Platform.runLater(() -> { myGists.getItems().clear(); }); ThreadUtil.wait(20); for (GHGist gist : gists) { String desc = gist.getDescription(); if (desc == null || desc.length() == 0) { desc = gist.getFiles().keySet().toArray()[0].toString(); } Menu tmpGist = new Menu(desc); MenuItem loadWebGist = new MenuItem("Show Web Gist..."); loadWebGist.setOnAction(event -> { String webURL = gist.getHtmlUrl(); try { BowlerStudio.openUrlInNewTab(new URL(webURL)); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } }); MenuItem addFile = new MenuItem("Add file to Gist..."); addFile.setOnAction(event -> { new Thread() { public void run() { } }.start(); }); Platform.runLater(() -> { tmpGist.getItems().addAll(addFile, loadWebGist); }); EventHandler<Event> loadFiles = new EventHandler<Event>() { @Override public void handle(Event ev) { // for(ScriptingEngine.) new Thread() { public void run() { System.out.println("Loading files"); ArrayList<String> listofFiles = ScriptingEngine .filesInGit(gist.getGitPushUrl(), "master", null); for (String s : listofFiles) { MenuItem tmp = new MenuItem(s); tmp.setOnAction(event -> { new Thread() { public void run() { try { File fileSelected = ScriptingEngine .fileFromGit(gist.getGitPushUrl(), s); BowlerStudio.createFileTab(fileSelected); } catch (Exception e) { // TODO // Auto-generated // catch block e.printStackTrace(); } } }.start(); }); Platform.runLater(() -> { tmpGist.getItems().add(tmp); tmpGist.setOnShowing(null); }); } Platform.runLater(() -> { tmpGist.hide(); Platform.runLater(() -> { tmpGist.show(); }); }); } }.start(); } }; tmpGist.setOnShowing(loadFiles); Platform.runLater(() -> { myGists.getItems().add(tmpGist); }); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } }.start(); }); }