Example usage for javafx.stage Stage close

List of usage examples for javafx.stage Stage close

Introduction

In this page you can find the example usage for javafx.stage Stage close.

Prototype

public void close() 

Source Link

Document

Closes this Stage .

Usage

From source file:ambroafb.general.StagesContainer.java

private static void callStageCloseRequest(Stage currStage) {
    if (currStage.getOnCloseRequest() == null) {
        currStage.close();
    } else {/*from  w w w  . j  a  va 2 s .co  m*/
        currStage.getOnCloseRequest().handle(null);
    }
}

From source file:jlotoprint.MainViewController.java

public static Stage loadTemplateChooser() {
    final Stage stage = new Stage();
    try {//from  www  . j  a va  2  s  .  c om
        FXMLLoader dialog = new FXMLLoader(MainViewController.class.getResource("TemplateDialog.fxml"));
        Parent root = (Parent) dialog.load();
        root.addEventHandler(TemplateDialogEvent.CANCELED, (actionEvent) -> {
            stage.close();
        });
        stage.setScene(new Scene(root));
        stage.setTitle("Choose a template");
        stage.getIcons().add(new Image("file:resources/icon.png"));
        stage.initModality(Modality.WINDOW_MODAL);
        stage.initOwner(JLotoPrint.stage.getScene().getWindow());
        stage.show();
    } catch (IOException ex) {
        Logger.getLogger(MainViewController.class.getName()).log(Level.SEVERE, null, ex);
        return null;
    }
    return stage;
}

From source file:ambroafb.general.StagesContainer.java

/**
 * The function closes children stages and after that it close the given stage.
 * @param currStage Current stage.//from   ww w  . jav a 2s.c o  m
 * @return True if current stage must close, false otherwise.
 */
public static boolean closeStageWithChildren(Stage currStage) {
    boolean childClosePermission = true;
    String currStagePath = (String) bidmap.getKey(currStage);

    List<String> childrenPath = getFirstLevelChildrenFor(currStagePath);
    if (childrenPath.isEmpty()) {
        if (currStage instanceof UserInteractiveDialogStage) {
            callStageCloseRequest(currStage);
            childClosePermission = ((UserInteractiveDialogStage) currStage).getPermissionToClose();
        } else if (currStage instanceof Filterable) {
            callStageCloseRequest(currStage);
        } else {
            currStage.close(); // this is needed, without this, program can cyclic. It may close table view list stage
        }
    } else {
        for (String childPath : childrenPath) {
            childClosePermission = closeStageWithChildren((Stage) bidmap.get(childPath))
                    && childClosePermission;
        }
        if (currStage.isShowing() && childClosePermission
                && !((String) bidmap.getKey(currStage)).equals("main")) {
            currStage.close();
        }
    }
    return childClosePermission;
}

From source file:net.sf.anathema.framework.presenter.action.about.AnathemaAboutAction.java

private void closeDialog(Stage stage) {
    stage.close();
}

From source file:ExcelFx.InitalDataController.java

@FXML
protected void cancelButton(ActionEvent event) throws IOException {
    Stage stage = (Stage) gridPane.getScene().getWindow();
    stage.close();

}

From source file:jasperreports.FXMLDocumentController.java

@FXML
public void close(ActionEvent event) {
    Stage stage = (Stage) pane.getScene().getWindow();
    stage.close();
}

From source file:by.zuyeu.deyestracker.reader.ui.readpane.ReadPaneController.java

/**
 * Close application/*from   ww w  .java 2s  .c  o  m*/
 *
 * @param event
 */
@FXML
public void closeButtonAction(ActionEvent event) {
    LOG.info("closeButtonAction() - start;");
    Stage stage = application.getStage();
    stage.close();
    LOG.info("closeButtonAction() - end;");
}

From source file:ExcelFx.InitalDataController.java

@FXML
protected void okButton(ActionEvent event) throws IOException {
    DropShadow ds = new DropShadow();
    ds.setColor(Color.RED);/*  w ww  .  j  a  va2  s  .  co m*/

    String err = "";
    if (initalField.getText().length() == 0) {
        err += "  ";
        initalField.setEffect(ds);

    }
    if (initalPage.getText().length() == 0) {
        err += " ?  excel  ";
        initalPage.setEffect(ds);

    }
    if (yStart.getText().length() == 0) {
        err += "   ? ";
        yStart.setEffect(ds);

    }
    if (yEnd.getText().length() == 0) {
        err += "   ? ";
        yEnd.setEffect(ds);

    }

    if (err.length() != 0) {
        Alert alert = new Alert(Alert.AlertType.INFORMATION);
        alert.setTitle("");
        alert.setHeaderText("?  ?");
        alert.setContentText(err);
        alert.showAndWait();

    } else {
        Stage stage = (Stage) gridPane.getScene().getWindow();
        stage.close();
        this.codes.setPatch(this.initalField.getText());
        this.codes.setPage((this.initalPage.getText()).trim().toLowerCase());
        this.codes.setYStart(this.yStart.getText().trim().toLowerCase());
        this.codes.setYEnd(this.yEnd.getText().trim().toLowerCase());
        this.codes.jsonCreate("inital.json");

    }
    this.gridPane.setUserData(this.codes);

}

From source file:sonicScream.controllers.ProfileManagerController.java

@FXML
private void handleOkButtonPressed(ActionEvent event) {
    SettingsService settings = (SettingsService) ServiceLocator.getService(SettingsService.class);
    //Add newly-added profiles if there are no name conflicts
    _profiles.stream().filter((p) -> (settings.getProfile(p.getProfileName()) == null)).forEach((p) -> {
        try {//from   ww w .  ja  va 2 s  . co m
            settings.addProfile(p);
            settings.saveSettings();
        } catch (ProfileNameExistsException ex) {
            //Collect the bad profile names here
            System.err.println(ex);
        }
    });
    //TODO: Tell the user there were name conflicts. Ask them "hey dude you 
    //sure bout this", and cancel closing if they say "no"

    selectedProfile.set((Profile) SelectedProfileComboBox.getValue());
    Stage currentStage = (Stage) SelectedProfileComboBox.getScene().getWindow();
    currentStage.close();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Text text = new Text("!");
    text.setFont(new Font(40));
    VBox box = new VBox();
    box.getChildren().add(text);//from  w  w  w.ja v  a2s  . c  o m
    final Scene scene = new Scene(box, 300, 250);
    scene.setFill(null);
    stage.setScene(scene);
    stage.show();
    stage.close();
}