Example usage for javafx.application Platform exit

List of usage examples for javafx.application Platform exit

Introduction

In this page you can find the example usage for javafx.application Platform exit.

Prototype

public static void exit() 

Source Link

Document

Causes the JavaFX application to terminate.

Usage

From source file:sh.isaac.api.util.ArtifactUtilities.java

/**
 * The main method./*from  ww  w .  jav  a2 s  .c o m*/
 *
 * @param args the arguments
 * @throws InterruptedException the interrupted exception
 * @throws ExecutionException the execution exception
 * @throws IOException Signals that an I/O exception has occurred.
 */
public static void main(String[] args) throws InterruptedException, ExecutionException, IOException {
    try {
        final String username = "foo";
        final String userpd = "foo";

        LookupService.startupWorkExecutors();

        final URL release = new URL("http://artifactory.isaac.sh/artifactory/libs-release-local"
                + makeMavenRelativePath("aopalliance", "aopalliance", "1.0", null, "jar"));
        Task<File> task = new DownloadUnzipTask(null, null, release, false, true, null);

        Get.workExecutors().getExecutor().submit(task);

        File foo = task.get();

        System.out.println(foo.getCanonicalPath());
        foo.delete();
        foo.getParentFile().delete();

        final File where = new File("").getAbsoluteFile();
        URL snapshot = new URL("http://artifactory.isaac.sh/artifactory/libs-snapshot"
                + makeMavenRelativePath("http://artifactory.isaac.sh/artifactory/libs-snapshot", username,
                        userpd, "sh.isaac.db", "vhat", "2016.01.07-1.0-SNAPSHOT", "all", "cradle.zip"));

        task = new DownloadUnzipTask(username, userpd, snapshot, true, true, where);
        Get.workExecutors().getExecutor().submit(task);
        foo = task.get();
        snapshot = new URL("http://artifactory.isaac.sh/artifactory/libs-snapshot"
                + makeMavenRelativePath("http://artifactory.isaac.sh/artifactory/libs-snapshot", username,
                        userpd, "sh.isaac.db", "vhat", "2016.01.07-1.0-SNAPSHOT", "all", "lucene.zip"));
        task = new DownloadUnzipTask(username, userpd, snapshot, true, true, where);
        Get.workExecutors().getExecutor().submit(task);
        foo = task.get();
        System.out.println(foo.getCanonicalPath());
    } catch (final Exception e) {
        e.printStackTrace();
    }

    Platform.exit();
}

From source file:io.uploader.drive.DriveUploader.java

public static void main(String[] args) {

    if (isMacOsX()) {
        System.setProperty("apple.laf.useScreenMenuBar", "true");
        System.setProperty("com.apple.mrj.application.apple.menu.about.name",
                Configuration.INSTANCE.getAppName());
        try {/*from   w w w  . ja v  a 2  s  . co m*/
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException
                | UnsupportedLookAndFeelException e) {
            logger.error("Error occurred while initializing the UI", e);
        }
    }

    Platform.setImplicitExit(false);

    // load the settings
    String settingsFile = "driveuploader-settings.xml";
    if (!new java.io.File(settingsFile).exists())
        settingsFile = null;
    try {
        Configuration.INSTANCE.load(settingsFile);
    } catch (ConfigurationException e) {
        logger.error("Error occurred while initializing the configuration", e);
    }

    try {
        // initialize the transport
        httpTransport = GoogleNetHttpTransport.newTrustedTransport();

        // initialize the data store factory
        dataStoreFactory = new FileDataStoreFactory(DATA_STORE_DIR);

    } catch (IOException e) {
        logger.error("Error occurred while initializing the drive", e);
        Platform.exit();
    } catch (Throwable t) {
        logger.error("Error occurred while initializing the drive", t);
        Platform.exit();
    }

    launch(args);
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Button exitBtn = new Button("Exit");
    exitBtn.setOnAction(e -> Platform.exit());

    VBox root = new VBox();
    root.getChildren().add(exitBtn);/*from w w w .  j  ava  2s  .  c o  m*/

    Scene scene = new Scene(root, 300, 50);
    stage.setScene(scene);
    stage.setTitle("Hello JavaFX Application with a Scene");
    stage.show();
}

From source file:Main.java

private MenuItem exitMenuItem() {
    MenuItem exitMenuItem = new MenuItem("Exit");
    exitMenuItem.setOnAction(actionEvent -> Platform.exit());

    return exitMenuItem;
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    BorderPane root = new BorderPane();
    Scene scene = new Scene(root, 300, 250, Color.WHITE);

    MenuBar menuBar = new MenuBar();
    menuBar.prefWidthProperty().bind(primaryStage.widthProperty());
    root.setTop(menuBar);/* w ww.  j  ava2  s.  co  m*/

    Menu fileMenu = new Menu("File");
    MenuItem exitMenuItem = new MenuItem("Exit");
    fileMenu.getItems().add(exitMenuItem);
    exitMenuItem.setOnAction(actionEvent -> Platform.exit());

    menuBar.getMenus().addAll(fileMenu);

    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:Main.java

@Override
 public void start(Stage stage) {
     String name = Thread.currentThread().getName();
     System.out.println("start() method: " + name);

     // Add an Exit button to the scene
     Button exitBtn = new Button("Exit");
     exitBtn.setOnAction(e -> Platform.exit());

     Scene scene = new Scene(new Group(exitBtn), 300, 100);
     stage.setScene(scene);/*  w w w.ja va 2s. c  o  m*/
     stage.setTitle("JavaFX Application Life Cycle");
     stage.show();
 }

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    BorderPane root = new BorderPane();
    Scene scene = new Scene(root, 300, 250, Color.WHITE);

    MenuBar menuBar = new MenuBar();
    menuBar.prefWidthProperty().bind(primaryStage.widthProperty());
    root.setTop(menuBar);/*from  w  w  w  . j  av a  2s  .c  o  m*/

    Menu fileMenu = new Menu("_File");
    fileMenu.setMnemonicParsing(true);
    MenuItem exitMenuItem = new MenuItem("Exit");
    fileMenu.getItems().add(exitMenuItem);
    exitMenuItem.setOnAction(actionEvent -> Platform.exit());

    menuBar.getMenus().addAll(fileMenu);

    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Label nameLbl = new Label("Enter your name:");
    TextField nameFld = new TextField();

    Label msg = new Label();
    msg.setStyle("-fx-text-fill: blue;");

    Button sayHelloBtn = new Button("Say Hello");
    Button exitBtn = new Button("Exit");

    sayHelloBtn.setOnAction(e -> {// w  w  w.  ja  v a 2s .c o  m
        String name = nameFld.getText();
        if (name.trim().length() > 0) {
            msg.setText("Hello " + name);
        } else {
            msg.setText("Hello there");
        }
    });

    exitBtn.setOnAction(e -> Platform.exit());

    VBox root = new VBox();

    root.setSpacing(5);
    root.getChildren().addAll(nameLbl, nameFld, msg, sayHelloBtn, exitBtn);

    Scene scene = new Scene(root, 350, 150);
    stage.setScene(scene);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    BorderPane root = new BorderPane();
    Scene scene = new Scene(root, 300, 250, Color.WHITE);

    MenuBar menuBar = new MenuBar();
    menuBar.prefWidthProperty().bind(primaryStage.widthProperty());
    root.setTop(menuBar);//from   w ww  .j  a  va 2s  .co m

    // File menu - new, save, exit
    Menu fileMenu = new Menu("File");
    MenuItem newMenuItem = new MenuItem("New");
    MenuItem saveMenuItem = new MenuItem("Save");
    MenuItem exitMenuItem = new MenuItem("Exit");
    exitMenuItem.setOnAction(actionEvent -> Platform.exit());

    fileMenu.getItems().addAll(newMenuItem, saveMenuItem, new SeparatorMenuItem(), exitMenuItem);

    Menu webMenu = new Menu("Web");
    CheckMenuItem htmlMenuItem = new CheckMenuItem("HTML");
    htmlMenuItem.setSelected(true);
    webMenu.getItems().add(htmlMenuItem);

    CheckMenuItem cssMenuItem = new CheckMenuItem("CSS");
    cssMenuItem.setSelected(true);
    webMenu.getItems().add(cssMenuItem);

    Menu sqlMenu = new Menu("SQL");
    ToggleGroup tGroup = new ToggleGroup();
    RadioMenuItem mysqlItem = new RadioMenuItem("MySQL");
    mysqlItem.setToggleGroup(tGroup);

    RadioMenuItem oracleItem = new RadioMenuItem("Oracle");
    oracleItem.setToggleGroup(tGroup);
    oracleItem.setSelected(true);

    sqlMenu.getItems().addAll(mysqlItem, oracleItem, new SeparatorMenuItem());

    Menu tutorialManeu = new Menu("Tutorial");
    tutorialManeu.getItems().addAll(new CheckMenuItem("Java"), new CheckMenuItem("JavaFX"),
            new CheckMenuItem("Swing"));

    sqlMenu.getItems().add(tutorialManeu);

    menuBar.getMenus().addAll(fileMenu, webMenu, sqlMenu);

    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    TextField fName = new TextField();
    TextField lName = new TextField();
    TextField salary = new TextField();

    Button closeBtn = new Button("Close");
    closeBtn.setOnAction(e -> Platform.exit());

    fName.getProperties().put("microHelpText", "Enter the first name");
    lName.getProperties().put("microHelpText", "Enter the last name");
    salary.getProperties().put("microHelpText", "Enter a salary greater than $2000.00.");

    // The help text node is unmanaged
    helpText.setManaged(false);//from www. j a  va 2s.  co m
    helpText.setTextOrigin(VPos.TOP);
    helpText.setFill(Color.RED);
    helpText.setFont(Font.font(null, 9));
    helpText.setMouseTransparent(true);

    // Add all nodes to a GridPane
    GridPane root = new GridPane();

    root.add(new Label("First Name:"), 1, 1);
    root.add(fName, 2, 1);
    root.add(new Label("Last Name:"), 1, 2);
    root.add(lName, 2, 2);

    root.add(new Label("Salary:"), 1, 3);
    root.add(salary, 2, 3);
    root.add(closeBtn, 3, 3);
    root.add(helpText, 4, 3);

    Scene scene = new Scene(root, 300, 100);

    // Add a change listener to the scene, so we know when
    // the focus owner changes and display the micro help   
    scene.focusOwnerProperty().addListener((ObservableValue<? extends Node> value, Node oldNode,
            Node newNode) -> focusChanged(value, oldNode, newNode));
    stage.setScene(scene);
    stage.setTitle("Showing Micro Help");
    stage.show();
}