Java Code Examples for javafx.stage.Window#hide()

The following examples show how to use javafx.stage.Window#hide() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainMenuController.java    From MyBox with Apache License 2.0 6 votes vote down vote up
@FXML
protected void closeOtherWindows(ActionEvent event) {
    List<Window> windows = new ArrayList<>();
    windows.addAll(Window.getWindows());
    for (Window window : windows) {
        if (parentController != null) {
            if (!window.equals(parentController.getMyStage())) {
                window.hide();
            }
        } else {
            if (!window.equals(myStage)) {
                window.hide();
            }
        }
    }
}
 
Example 2
Source File: ScoresDialogController.java    From examples-javafx-repos1 with Apache License 2.0 5 votes vote down vote up
@FXML
public void close(ActionEvent evt) {

    Scene scene = ((Button)evt.getSource()).getScene();
    if( scene != null ) {
        Window w = scene.getWindow();
        if (w != null) {
            w.hide();
        }
    }
}
 
Example 3
Source File: WindowsMenu.java    From mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
private void closeAllWindows() {
  // Close all JavaFX Windows
  final var allWindows = ImmutableList.copyOf(Stage.getWindows());
  for (Window window : allWindows) {
    if (window == MZmineCore.getDesktop().getMainWindow())
      continue;
    logger.finest("Closing window " + window);
    window.hide();
  }
}
 
Example 4
Source File: SettingsDialogController.java    From examples-javafx-repos1 with Apache License 2.0 5 votes vote down vote up
@FXML
public void close(ActionEvent evt) {

    //
    // For some reason, this.getScene() which is on the fx:root returns null
    //

    Scene scene = ((Button)evt.getSource()).getScene();
    if( scene != null ) {
        Window w = scene.getWindow();
        if (w != null) {
            w.hide();
        }
    }
}
 
Example 5
Source File: AboutDialogController.java    From examples-javafx-repos1 with Apache License 2.0 5 votes vote down vote up
@FXML
public void close(ActionEvent evt) {

    //
    // For some reason, this.getScene() which is on the fx:root returns null
    //

    Scene scene = ((Button)evt.getSource()).getScene();
    if( scene != null ) {
        Window w = scene.getWindow();
        if (w != null) {
            w.hide();
        }
    }
}
 
Example 6
Source File: HelpDialogController.java    From examples-javafx-repos1 with Apache License 2.0 5 votes vote down vote up
@FXML
public void close(ActionEvent evt) {

    //
    // For some reason, this.getScene() which is on the fx:root returns null
    //

    Scene scene = ((Button)evt.getSource()).getScene();
    if( scene != null ) {
        Window w = scene.getWindow();
        if (w != null) {
            w.hide();
        }
    }
}
 
Example 7
Source File: ScoresDialogController.java    From examples-javafx-repos1 with Apache License 2.0 5 votes vote down vote up
@FXML
public void close(ActionEvent evt) {

    Scene scene = ((Button)evt.getSource()).getScene();
    if( scene != null ) {
        Window w = scene.getWindow();
        if (w != null) {
            w.hide();
        }
    }
}
 
Example 8
Source File: SettingsDialogController.java    From examples-javafx-repos1 with Apache License 2.0 5 votes vote down vote up
@FXML
public void close(ActionEvent evt) {

    //
    // For some reason, this.getScene() which is on the fx:root returns null
    //

    Scene scene = ((Button)evt.getSource()).getScene();
    if( scene != null ) {
        Window w = scene.getWindow();
        if (w != null) {
            w.hide();
        }
    }
}
 
Example 9
Source File: AboutDialogController.java    From examples-javafx-repos1 with Apache License 2.0 5 votes vote down vote up
@FXML
public void close(ActionEvent evt) {

    //
    // For some reason, this.getScene() which is on the fx:root returns null
    //

    Scene scene = ((Button)evt.getSource()).getScene();
    if( scene != null ) {
        Window w = scene.getWindow();
        if (w != null) {
            w.hide();
        }
    }
}
 
Example 10
Source File: HelpDialogController.java    From examples-javafx-repos1 with Apache License 2.0 5 votes vote down vote up
@FXML
public void close(ActionEvent evt) {

    //
    // For some reason, this.getScene() which is on the fx:root returns null
    //

    Scene scene = ((Button)evt.getSource()).getScene();
    if( scene != null ) {
        Window w = scene.getWindow();
        if (w != null) {
            w.hide();
        }
    }
}
 
Example 11
Source File: Synchronization.java    From PeerWasp with MIT License 5 votes vote down vote up
/**
 * This method is bound to the fxml of the view and is invoked
 * by clicks on the "Cancel" button.
 * @param event that was fired.
 */
@FXML
public void cancelAction(ActionEvent event) {
	if(event.getTarget() != null && event.getTarget() instanceof Button){
		Button cancelButton = (Button)event.getTarget();
		Window window = cancelButton.getScene().getWindow();
		window.hide();
	}
}
 
Example 12
Source File: SettingsDialogController.java    From examples-javafx-repos1 with Apache License 2.0 5 votes vote down vote up
@FXML
public void close(ActionEvent evt) {

    //
    // For some reason, this.getScene() which is on the fx:root returns null
    //

    Scene scene = ((Button)evt.getSource()).getScene();
    if( scene != null ) {
        Window w = scene.getWindow();
        if (w != null) {
            w.hide();
        }
    }
}
 
Example 13
Source File: AboutDialogController.java    From examples-javafx-repos1 with Apache License 2.0 5 votes vote down vote up
@FXML
public void close(ActionEvent evt) {

    //
    // For some reason, this.getScene() which is on the fx:root returns null
    //

    Scene scene = ((Button)evt.getSource()).getScene();
    if( scene != null ) {
        Window w = scene.getWindow();
        if (w != null) {
            w.hide();
        }
    }
}
 
Example 14
Source File: HelpDialogController.java    From examples-javafx-repos1 with Apache License 2.0 5 votes vote down vote up
@FXML
public void close(ActionEvent evt) {

    //
    // For some reason, this.getScene() which is on the fx:root returns null
    //

    Scene scene = ((Button)evt.getSource()).getScene();
    if( scene != null ) {
        Window w = scene.getWindow();
        if (w != null) {
            w.hide();
        }
    }
}
 
Example 15
Source File: ScoresViewController.java    From examples-javafx-repos1 with Apache License 2.0 5 votes vote down vote up
@FXML
public void close(ActionEvent evt) {

    Scene scene = ((Button)evt.getSource()).getScene();
    if( scene != null ) {
        Window w = scene.getWindow();
        if (w != null) {
            w.hide();
        }
    }
}
 
Example 16
Source File: AboutViewController.java    From examples-javafx-repos1 with Apache License 2.0 5 votes vote down vote up
@FXML
public void close(ActionEvent evt) {

    //
    // For some reason, this.getScene() which is on the fx:root returns null
    //

    Scene scene = ((Button)evt.getSource()).getScene();
    if( scene != null ) {
        Window w = scene.getWindow();
        if (w != null) {
            w.hide();
        }
    }
}
 
Example 17
Source File: HelpViewController.java    From examples-javafx-repos1 with Apache License 2.0 5 votes vote down vote up
@FXML
public void close(ActionEvent evt) {

    //
    // For some reason, this.getScene() which is on the fx:root returns null
    //

    Scene scene = ((Button)evt.getSource()).getScene();
    if( scene != null ) {
        Window w = scene.getWindow();
        if (w != null) {
            w.hide();
        }
    }
}
 
Example 18
Source File: SettingsViewController.java    From examples-javafx-repos1 with Apache License 2.0 5 votes vote down vote up
@FXML
public void close(ActionEvent evt) {

    //
    // For some reason, this.getScene() which is on the fx:root returns null
    //

    Scene scene = ((Button)evt.getSource()).getScene();
    if( scene != null ) {
        Window w = scene.getWindow();
        if (w != null) {
            w.hide();
        }
    }
}
 
Example 19
Source File: ImportWizardController.java    From pikatimer with GNU General Public License v3.0 5 votes vote down vote up
/**
     * This method will be called when the {@code finish} action will be executed. The method handles the navigation of
     * the internal flow that contains the steps of the wizard as separate views. In addition the states of the action
     * buttons will be managed.
     * @throws VetoException If the navigation can't be executed
     * @throws FlowException If the navigation can't be executed
     */
    @ActionMethod("close")
    public void onFinish() throws VetoException, FlowException {
        Window stage = closeButton.getScene().getWindow();
//        flowHandler.navigateTo(ImportWizardView3Controller.class);
//        closeButton.setDisable(true);
//        nextButton.setDisable(true);
//        backButton.setDisable(false);
        stage.hide();
    }
 
Example 20
Source File: FxmlStage.java    From MyBox with Apache License 2.0 4 votes vote down vote up
public static void appExit() {
        try {
//            if (AppVariables.backgroundTasks != null && !AppVariables.backgroundTasks.isEmpty()) {
//                Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
//                alert.setContentText(MessageFormat.format(message("BackgroundTasksRunning"), AppVariables.backgroundTasks.size()));
//                alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE);
//                Stage stage = (Stage) alert.getDialogPane().getScene().getWindow();
//                stage.setAlwaysOnTop(true);
//                stage.toFront();
//                Optional<ButtonType> result = alert.showAndWait();
//                if (result.get() == null || result.get() != ButtonType.OK) {
//                    return;
//                }
//            }

            if (Window.getWindows() != null) {
                List<Window> windows = new ArrayList<>();
                windows.addAll(Window.getWindows());
                for (Window window : windows) {
                    window.hide();
                }
            }

            if (AppVariables.scheduledTasks != null && !AppVariables.scheduledTasks.isEmpty()) {
                if (AppVariables.getUserConfigBoolean("StopAlarmsWhenExit")) {
                    for (Long key : AppVariables.scheduledTasks.keySet()) {
                        ScheduledFuture future = AppVariables.scheduledTasks.get(key);
                        future.cancel(true);
                    }
                    AppVariables.scheduledTasks = null;
                    if (AppVariables.executorService != null) {
                        AppVariables.executorService.shutdownNow();
                        AppVariables.executorService = null;
                    }
                }

            } else {
                if (AppVariables.scheduledTasks != null) {
                    AppVariables.scheduledTasks = null;
                }
                if (AppVariables.executorService != null) {
                    AppVariables.executorService.shutdownNow();
                    AppVariables.executorService = null;
                }
            }

            if (AppVariables.scheduledTasks == null || AppVariables.scheduledTasks.isEmpty()) {

//                logger.debug("Shut down Derby server...");
//                DerbyBase.shutdownDerbyServer();
                logger.debug("Exit now. Bye!");
                Platform.exit(); // Some thread may still be alive after this
                System.exit(0);  // Go
            }

        } catch (Exception e) {
            logger.debug(e.toString());
        }

    }