/* * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. */ package tests; import java.io.File; import java.util.List; import javafx.application.Application; import javafx.application.Platform; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.control.*; import javafx.scene.input.KeyEvent; import javafx.stage.FileChooser; import javafx.stage.Stage; public class Test extends Application { @Override public void start(Stage stage) { stage.setTitle("Sample"); Scene scene = new Scene(new Group(), 500, 500); Group root = (Group) scene.getRoot(); final MenuItem menuItem = new MenuItem("Quit"); menuItem.setOnAction(new EventHandler() { @Override public void handle(ActionEvent t) { Platform.exit(); } }); final Menu menu = new Menu("Main menu"); menu.getItems().add(menuItem); final MenuBar menuBar = new MenuBar(); menuBar.getMenus().add(menu); final Button button = new Button("Open file chooser"); button.setLayoutX(100); button.setLayoutY(100); button.setOnAction(new EventHandler() { @Override public void handle(ActionEvent t) { final FileChooser fileChooser = new FileChooser(); final List files = fileChooser.showOpenMultipleDialog(null); System.err.println("Files = " + files); } }); root.getChildren().clear(); root.getChildren().addAll(menuBar, button); stage.setScene(scene); stage.show(); } /** * @param args the command line arguments */ public static void main(String[] args) { Application.launch(args); } }