Example usage for javafx.scene.control Button Button

List of usage examples for javafx.scene.control Button Button

Introduction

In this page you can find the example usage for javafx.scene.control Button Button.

Prototype

public Button() 

Source Link

Document

Creates a button with an empty string for its label.

Usage

From source file:patientmanagerv1.HomeController.java

public void printAdv() {
    final Stage dialog = new Stage();
    dialog.initModality(Modality.APPLICATION_MODAL);

    final TextField textField = new TextField();
    Button submit = new Button();
    Button cancel = new Button();
    final Label label = new Label();

    cancel.setText("Cancel");
    cancel.setAlignment(Pos.CENTER);//from   w w w .j a v a  2 s .  c  o  m
    submit.setText("Submit");
    submit.setAlignment(Pos.BOTTOM_RIGHT);

    final VBox dialogVbox = new VBox(20);
    dialogVbox.getChildren().add(new Text("Enter the master password: "));
    dialogVbox.getChildren().add(textField);
    dialogVbox.getChildren().add(submit);
    dialogVbox.getChildren().add(cancel);
    dialogVbox.getChildren().add(label);

    Scene dialogScene = new Scene(dialogVbox, 300, 200);
    dialog.setScene(dialogScene);
    dialog.setTitle("Security/Physician Authentication");
    dialog.show();

    submit.setOnAction(new EventHandler<ActionEvent>() {

        public void handle(ActionEvent anEvent) {
            String password = textField.getText();

            if (password.equalsIgnoreCase("protooncogene")) {
                dialog.close();

                writeEvalToDocX(false, "");

                //OPENS the document for printing:
                try {
                    if (Desktop.isDesktopSupported()) {
                        Desktop.getDesktop()
                                .open(new File(installationPath + "/userdata/" + firstName + lastName + dob
                                        + "/" + firstName + lastName + dob + "psychiatricevaluation.docx"));
                    }
                } catch (IOException ioe) {
                    ioe.printStackTrace();
                }
            } else {
                label.setText("The password you entered is incorrect. Please try again.");
            }

            //adds files to file tracker

        }
    });

    cancel.setOnAction(new EventHandler<ActionEvent>() {

        public void handle(ActionEvent anEvent) {
            dialog.close();
            //close the window here
        }
    });

}