Java Code Examples for javafx.stage.Stage#close()

The following examples show how to use javafx.stage.Stage#close() . 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: ConfKeybinding.java    From Recaf with MIT License 7 votes vote down vote up
private void handleWindowKeyEvents(KeyEvent e, GuiController controller, Stage stage, boolean main) {
	if(!main && closeWindow.match(e))
		stage.close();
	if(saveApp.match(e))
		controller.windows().getMainWindow().saveApplication();
	else {
		// Custom bind support
		PluginKeybinds.getInstance().getGlobalBinds().forEach((bind, action) -> {
			try {
				if (bind.match(e))
					action.run();
			} catch(Throwable t) {
				Log.error(t, "Failed executing global keybind action");
			}
		});
	}
}
 
Example 2
Source File: ChangeAssetRepoController.java    From BowlerStudio with GNU General Public License v3.0 7 votes vote down vote up
@FXML
public void onChangeRepo(ActionEvent event)
   {
	String repo =  repoField.getText()
               .replaceAll("git://", "https://");
	new Thread(()->{
        ConfigurationDatabase.setObject("BowlerStudioConfigs", "skinRepo",
        		repo);
		ConfigurationDatabase.save();

	}).start();

       Stage stage = (Stage) changeRepoButton.getScene().getWindow();
       stage.close();
       
   }
 
Example 3
Source File: EditArrayRegistersController.java    From CPUSim with GNU General Public License v3.0 7 votes vote down vote up
/**
 * save the current changes and close the window when clicking on OK button.
 *
 * @param e a type of action when a button is clicked.
 */
@FXML
public void onOKButtonClick(ActionEvent e) {
    //get the current edited clones
    ObservableList objList = activeTable.getItems();
    try {
        ObservableList<Register> list = FXCollections.observableArrayList();
        list.addAll(registerController.getItems());
        for (RegisterArrayTableView r : tableMap.getMap().values()) {
            list.addAll(r.getItems());
        }
        Validate.allNamesAreUnique(list.toArray());
        getCurrentController().checkValidity(objList);
        //update the machine with the new values
        updateRegisters();
        //get a handle to the stage.
        Stage stage = (Stage) okButton.getScene().getWindow();
        //close window.
        stage.close();
    } catch (Exception ex) {
        Dialogs.createErrorDialog(tablePane.getScene().getWindow(),
                "Registers Error", ex.getMessage()).showAndWait();
    }
}
 
Example 4
Source File: HelloWorldController.java    From Learn-Java-12-Programming with MIT License 7 votes vote down vote up
@FXML
protected void submitClicked(ActionEvent e) {
    String fn = tfFirstName.getText();
    String ln = tfLastName.getText();
    String age = tfAge.getText();
    int a = 42;
    try {
        a = Integer.parseInt(age);
    } catch (Exception ex) {
    }
    fn = fn.isBlank() ? "Nick" : fn;
    ln = ln.isBlank() ? "Samoylov" : ln;
    String user = "Hello, " + fn + " " + ln + ", age " + a + "!";
    //System.out.println("\nHello, " + fn + " " + ln + ", age " + a + "!");
    //Platform.exit();

    goToPage2(user);
    Node source = (Node) e.getSource();
    Stage stage = (Stage) source.getScene().getWindow();
    stage.close();
}
 
Example 5
Source File: EditModulesController.java    From CPUSim with GNU General Public License v3.0 6 votes vote down vote up
/**
 * save the current changes and close the window when clicking on OK button.
 *
 * @param e a type of action when a button is clicked.
 */
@FXML
public void onOKButtonClick(ActionEvent e) {
    //get the current edited clones
    //ObservableList objList = activeTable.getItems();
    try {

        String[] controllerStrings = {"Register", "RegisterArray", "ConditionBit",
                "RAM"};
        for (String controller : controllerStrings) {
            getController(controller).checkValidity();
        }

        //update the machine with the new values
        updateMachine();
        //get a handle to the stage.
        Stage stage = (Stage) okButton.getScene().getWindow();
        //close window.
        stage.close();

        mediator.addPropertyChangeListenerToAllModules(mediator.getBackupManager());
        desktop.getHighlightManager().updatePairsForNewRegistersAndRAMs();
    } catch (ValidationException ex) {
        Dialogs.createErrorDialog(tablePane.getScene().getWindow(), "Modules " +
                "Error", ex.getMessage()).showAndWait();
    }

}
 
Example 6
Source File: EditArrayRegistersController.java    From CPUSim with GNU General Public License v3.0 6 votes vote down vote up
/**
 * close the window without saving the changes.
 *
 * @param e a type of action when a button is clicked.
 */
@FXML
public void onCancelButtonClick(ActionEvent e) {
    //get a handle to the stage.
    Stage stage = (Stage) cancelButton.getScene().getWindow();
    //close window.
    stage.close();
}
 
Example 7
Source File: Components.java    From proxyee-down with Apache License 2.0 6 votes vote down vote up
/**
 * 弹出文件夹选择框
 */
public static File dirChooser() {
  Stage stage = buildBackgroundTopStage();
  DirectoryChooser chooser = new DirectoryChooser();
  chooser.setTitle("选择文件夹");
  File file = chooser.showDialog(stage);
  stage.close();
  return file;
}
 
Example 8
Source File: TestMemoryLeaks.java    From cssfx with Apache License 2.0 6 votes vote down vote up
public static void cleanupFocusedStage() {
    // This is a workaround for https://bugs.openjdk.java.net/browse/JDK-8241840
    Stage stage = new Stage();
    stage.setScene(new Scene(new StackPane()));
    stage.show();
    stage.close();
    stage.requestFocus();
}
 
Example 9
Source File: Components.java    From proxyee-down with Apache License 2.0 6 votes vote down vote up
/**
 * 弹出文件选择框
 */
public static File fileChooser() {
  Stage stage = buildBackgroundTopStage();
  FileChooser chooser = new FileChooser();
  chooser.setTitle("选择文件");
  File file = chooser.showOpenDialog(stage);
  stage.close();
  return file;
}
 
Example 10
Source File: TestSpaceFXView.java    From SpaceFX with Apache License 2.0 6 votes vote down vote up
public void workaround() {
    Stage stage = new Stage();
    Scene scene = new Scene(new StackPane());
    stage.setScene(scene);
    stage.show();
    stage.close();
}
 
Example 11
Source File: FxmlStage.java    From MyBox with Apache License 2.0 6 votes vote down vote up
public static void closeStage(Stage stage) {
    try {
        stage.close();
        if (Window.getWindows().isEmpty()) {
            appExit();
        }
    } catch (Exception e) {
        logger.error(e.toString());
    }
}
 
Example 12
Source File: Popover2Controller.java    From HealthPlus with Apache License 2.0 4 votes vote down vote up
@FXML
public void closePopUp()
{
    Stage stage = (Stage) daysList.getScene().getWindow();
    stage.close();
}
 
Example 13
Source File: LogoutController.java    From HealthPlus with Apache License 2.0 4 votes vote down vote up
@FXML
private void cancel()
{
    Stage stage = (Stage) cancelButton.getScene().getWindow();
    stage.close();
}
 
Example 14
Source File: ServiceDetailedLostLuggageViewController.java    From Corendon-LostLuggage with MIT License 4 votes vote down vote up
/**  
 * Close the current stage by getting the window of a fields scene's
 * And casting this to a stage, and close this stage
 */ 
public void closeStage(){
    Stage stage = (Stage) registrationNr.getScene().getWindow();
    stage.close();
}
 
Example 15
Source File: ServiceDetailedFoundLuggageController.java    From Corendon-LostLuggage with MIT License 4 votes vote down vote up
/**  
 * Close the current stage by getting the window of a fields scene's
 * And casting this to a stage, and close this stage
 */ 
public void closeStage(){
    Stage stage = (Stage) registrationNr.getScene().getWindow();
    stage.close();
}
 
Example 16
Source File: WelcomeWizard.java    From Lipi with MIT License 4 votes vote down vote up
public static void openDirBlog(File blogDir, Stage primaryStage) {
        if (blogDir != null) {
            try {
                primaryStage.close();
                String selectedDirPath = blogDir.getCanonicalPath();

                //history is saved
                WelcomeWizard.storeBlogHistory(selectedDirPath);

                TomlConfig tomlConfig = new TomlConfig(selectedDirPath + File.separator + "config.toml");

                primaryStage.setTitle("Blog Dashboard: " + tomlConfig.getTomlMap().get("title").toString() + " - Lipi");

                Stage editorStage = new Stage();
                editorStage.setTitle("Lipi Post Editor");
                TabbedHMDPostEditor t = new TabbedHMDPostEditor(editorStage);
                t.getStylesheets().add(Paths.get("res/material.css").toAbsolutePath().toUri().toString());
                t.getStylesheets().add(Paths.get("res/custom.css").toAbsolutePath().toUri().toString());
                editorStage.setScene(new Scene(t));

                editorStage.getIcons().add(
                        new Image(Paths.get("res/lipi-hmdeditor-icon.png").toAbsolutePath().toUri().toString())
                );

                DashboardMain mainDashboard = new DashboardMain(selectedDirPath, t);

                VBox holder = new VBox();
//                holder.setMinHeight(680);
                holder.setMinWidth(1000);
                holder.getChildren().add(mainDashboard);

                holder.getStylesheets().add(Paths.get("res/material.css").toAbsolutePath().toUri().toString());
                holder.getStylesheets().add(Paths.get("res/custom.css").toAbsolutePath().toUri().toString());

                Scene scene = new Scene(holder);

                primaryStage.setScene(scene);

//                primaryStage.setMinHeight(680);
                primaryStage.setMinWidth(1000);

                primaryStage.show();
                primaryStage.centerOnScreen();


            } catch (IOException e) {
                ExceptionAlerter.showException(e);
                e.getMessage();
            }
        }
    }
 
Example 17
Source File: NewItemController.java    From tcMenu with Apache License 2.0 4 votes vote down vote up
private void closeIt() {
    Stage s = (Stage) subMenuSelect.getScene().getWindow();
    s.close();
}
 
Example 18
Source File: CodeGenLoggingController.java    From tcMenu with Apache License 2.0 4 votes vote down vote up
public void onClose(ActionEvent actionEvent) {
    Stage s = (Stage) loggingArea.getScene().getWindow();
    s.close();
}
 
Example 19
Source File: GameClientLauncherController.java    From Cardshifter with Apache License 2.0 4 votes vote down vote up
private void closeWithSuccess() {
	Node source = anchorPane;
	Stage stage = (Stage)source.getScene().getWindow();
	stage.close();
}
 
Example 20
Source File: ServiceConfirmedMatchLuggageViewController.java    From Corendon-LostLuggage with MIT License 2 votes vote down vote up
/**  
 * Close the current stage by getting the window of a fields scene's
 * And casting this to a stage, and close this stage
 * 
 */ 
public void closeStage(){
    Stage stage = (Stage) registrationNr.getScene().getWindow();
    stage.close();
}