本文整理汇总了Java中javafx.stage.Stage.setOnCloseRequest方法的典型用法代码示例。如果您正苦于以下问题:Java Stage.setOnCloseRequest方法的具体用法?Java Stage.setOnCloseRequest怎么用?Java Stage.setOnCloseRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.stage.Stage
的用法示例。
在下文中一共展示了Stage.setOnCloseRequest方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleAddNewDrug
import javafx.stage.Stage; //导入方法依赖的package包/类
@FXML
private void handleAddNewDrug(ActionEvent event) throws IOException {
FXMLLoader fXMLLoader = new FXMLLoader();
fXMLLoader.setLocation(getClass().getResource("/view/drug/NewDrug.fxml"));
Stage stage = new Stage();
Scene scene = new Scene(fXMLLoader.load());
stage.setScene(scene);
stage.initModality(Modality.APPLICATION_MODAL);
stage.setTitle("New Drug");
stage.show();
stage.setOnCloseRequest((WindowEvent event1) -> {
drugs.clear();
loadDrug();
});
}
示例2: start
import javafx.stage.Stage; //导入方法依赖的package包/类
public void start(Stage stg) throws IOException
{
guiroot = loader.load();
sc = new Scene(guiroot);
contr = loader.getController();
stg.setScene(sc);
stg.sizeToScene();
stg.setTitle("Plasmoxy::ThunderLord/VisionGama");
stg.setMinHeight(stg.getHeight());
stg.setMinWidth(stg.getWidth());
stg.show();
stg.setOnCloseRequest( event ->
{
System.out.println("CLOSING");
contr.close();
});
}
示例3: start
import javafx.stage.Stage; //导入方法依赖的package包/类
public void start(String name, Path path) throws IOException {
initializeExecutorAndError();
initializeProject(name, path);
initializeInject();
Stage stage = new Stage();
stage.setTitle(project.getTitle());
Screen screen = new Screen();
Scale scale = screen.calculateScale();
stage.setWidth(scale.getWidth());
stage.setHeight(scale.getHeight());
Point point = screen.calculateCenter(stage.getWidth(), stage.getHeight());
stage.setX(point.getX());
stage.setY(point.getY());
CustomIcons customIcons = new CustomIcons();
stage.getIcons().add(customIcons.getLogo());
stage.setOnCloseRequest(event -> System.exit(0));
WorkView workView = new WorkView();
Scene scene = new Scene(workView.getView());
stage.setScene(scene);
stage.show();
}
示例4: start
import javafx.stage.Stage; //导入方法依赖的package包/类
@Override
public void start(Stage primaryStage) {
try {
GridPane root = (GridPane)FXMLLoader.load(getClass().getClassLoader().getResource("mainMenu.fxml"));
Scene scene = new Scene(root,400,400);
//scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
primaryStage.setTitle("Vier Gewinnt: Hauptmenu");
primaryStage.setScene(scene);
primaryStage.setResizable(false);
primaryStage.setOnCloseRequest(event -> {
closeAppl();
});
primaryStage.show();
} catch(Exception e) {
e.printStackTrace();
}
}
示例5: bakersDozenMenuClick
import javafx.stage.Stage; //导入方法依赖的package包/类
@FXML protected void bakersDozenMenuClick() throws IOException {
Stage main = (Stage) _gameMenu.getScene().getWindow();
Parent bakersDozenFXML = FXMLLoader.load(getClass().getResource("/fxml/bakersDozenGame.fxml"));
bakersDozenFXML.getStylesheets().add("/stylesheets/bakersDozenGame.css");
Scene bakersDozenScene = new Scene(bakersDozenFXML);
main.setOnCloseRequest(b -> {
boolean response = ExitWindow.display("Confirm", "Are you sure you want to quit now?");
if(response) main.close();
b.consume();
});
main.setScene(bakersDozenScene);
main.show();
}
示例6: setupStage
import javafx.stage.Stage; //导入方法依赖的package包/类
private void setupStage(Stage s)
{
stage = s;
s.setTitle("Pinggers Git/SVN Client");
s.setHeight(480);
s.setWidth(800);
s.setMinHeight(480);
s.setMinWidth(480);
s.centerOnScreen();
// Prevent Closing of the Main Window when it is disabled
s.addEventFilter(WindowEvent.WINDOW_CLOSE_REQUEST, event -> {
if(root.isDisable())
{
event.consume();
}
});
// Use own Exit handling (double check for isDisable ...)
s.setOnCloseRequest(event -> {
requestExit();
event.consume();
});
}
示例7: start
import javafx.stage.Stage; //导入方法依赖的package包/类
@Override
public void start(Stage stage) throws Exception {
double x = Toolkit.getDefaultToolkit().getScreenSize().width * 0.75;
double y = Toolkit.getDefaultToolkit().getScreenSize().height * 0.75;
Parent root = FXMLLoader.load(getClass().getResource(GlobalConstants.MAIN_VIEW));
Scene scene = new Scene(root,x,y);
scene.getStylesheets().add(GlobalConstants.CSS);
stage.setOnCloseRequest(event ->{
File img = new File(LocalEnvironment.getLocalVar(Local.TMP));
File[] files = img.listFiles();
if(files != null){
for(File f : files){
if(f.getName().endsWith(".jpg") || f.getName().endsWith(".JPG")){
try {
Files.delete(f.toPath());
} catch (IOException ex) {
Logger.getLogger(MainApp.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
}
System.exit(0);
});
stage.setMinWidth(x);
stage.setMinHeight(y);
stage.setTitle(GlobalConstants.TITLE);
stage.setScene(scene);
stage.show();
stage.centerOnScreen();
}
示例8: start
import javafx.stage.Stage; //导入方法依赖的package包/类
@Override
public void start(Stage primaryStage) throws Exception {
primaryStage.setTitle("ClientGUI");
client = new Client(clientConsole);
GridPane gridPane = initGridPane();
Scene scene = new Scene(gridPane, 400, 400);
primaryStage.setScene(scene);
primaryStage.show();
help();
primaryStage.setResizable(false);
primaryStage.setOnCloseRequest(e -> Platform.exit());
}
示例9: SettingsView
import javafx.stage.Stage; //导入方法依赖的package包/类
/**
* Create a new instance of a {@link SettingsView}.
*
* @param settings {@link Settings} of the application
* @param fxmlLoader a {@link FXMLLoader} instance for instantiating the new window
*/
@Inject
public SettingsView(final Settings settings, final FXMLLoader fxmlLoader) {
try {
final Stage newStage = new Stage();
newStage.setResizable(false);
newStage.setTitle(TITLE);
final URL resource = getClass().getResource(SETTINGS_VIEW);
fxmlLoader.setLocation(resource);
final Parent parent = fxmlLoader.load();
if (parent == null) {
throw new UIInitialisationException("Root of Settings could not be found.");
}
final Stage primaryStage = Hygene.getInstance().getPrimaryStage();
newStage.initModality(Modality.WINDOW_MODAL);
newStage.initOwner(primaryStage);
newStage.setScene(new Scene(parent));
// TODO show prompt box asking the user if they want to close if they have unsaved settings.
newStage.setOnCloseRequest(request -> settings.clearAll());
setStage(newStage);
} catch (final IOException | UIInitialisationException e) {
LOGGER.error("Unable to initialize SettingsView.", e);
}
}
示例10: GenomeMappingView
import javafx.stage.Stage; //导入方法依赖的package包/类
/**
* Creates an instance of a {@link GenomeMappingView}.
*
* @throws IOException if unable to load the controller
*/
@Inject
public GenomeMappingView(final FXMLLoader fxmlLoader) throws UIInitialisationException, IOException {
stage = new Stage();
stage.setTitle(TITLE);
stage.initModality(Modality.APPLICATION_MODAL);
stage.setOnCloseRequest(Event::consume); // prevent user from closing stage directly
final URL resource = getClass().getResource(GENOME_MAPPING_VIEW);
fxmlLoader.setLocation(resource);
final Scene rootScene = new Scene(fxmlLoader.load());
stage.setScene(rootScene);
}
示例11: start
import javafx.stage.Stage; //导入方法依赖的package包/类
public void start(Stage primaryStage) throws Exception{
FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/main.fxml"));
Parent root = loader.load();
primaryStage.setTitle("ftp Sync");
primaryStage.setScene(new Scene(root, 1000, 700));
primaryStage.setMinWidth(800);
primaryStage.setMinHeight(700);
primaryStage.show();
// shutdown any running threads when application exit button is pressed
MainController controller = loader.getController();
primaryStage.setOnCloseRequest(e -> controller.shutdown());
}
示例12: start
import javafx.stage.Stage; //导入方法依赖的package包/类
@Override
public void start(Stage stage) throws Exception {
stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
@Override
public void handle(WindowEvent e)
{
Platform.exit();
}
});
Parent root = FXMLLoader.load(getClass().getResource("/com/miage/pandemie/view/index.fxml"));
Scene scene = new Scene(root);
stage.setScene(scene);
stage.show();
}
示例13: createAndShowTableWindow
import javafx.stage.Stage; //导入方法依赖的package包/类
private void createAndShowTableWindow(ComboBox<String> traceNameComboBox) {
openedWindowsCtr++;
List<String> traceNames = new ArrayList<>();
for (int i = 0; i < plotData.getAllTraces().size(); i++) {
traceNames.add(plotData.getAllTraces().get(i).getTraceName());
}
traceNameComboBox.setItems(FXCollections.observableList(traceNames));
traceNameComboBox.getSelectionModel().select(0);
HBox hbox = new HBox();
traceNameComboBox.getSelectionModel().select(0);
Region spacer = new Region();
HBox.setHgrow(spacer, Priority.ALWAYS);
hbox.getChildren().addAll(new Label("Please Select a trace :"), spacer, traceNameComboBox);
updateTableValues(traceNameComboBox);
Scene scene = new Scene(new Group());
VBox vbox = new VBox();
VBox.setVgrow(table, Priority.ALWAYS);
vbox.setSpacing(5);
vbox.setPadding(new Insets(10, 10, 10, 10));
vbox.prefWidthProperty().bind(scene.widthProperty());
vbox.prefHeightProperty().bind(scene.heightProperty());
vbox.getChildren().addAll(hbox, table);
((Group) scene.getRoot()).getChildren().addAll(vbox);
Stage stage = new Stage();
stage.setOnCloseRequest(e -> closeTableWindow());
stage.setWidth(300);
stage.setHeight(400);
stage.setScene(scene);
stage.sizeToScene();
stage.showAndWait();
}
示例14: loadUI
import javafx.stage.Stage; //导入方法依赖的package包/类
/**
* Loads the main UI.
*
* @param primaryStage
* the stage to use for displaying the UI
*/
private void loadUI(final Stage primaryStage) {
stage = primaryStage;
final MainController controller = loadUIAndGetController();
TrayNotificationBuilder.setDefaultOwner(stage);
primaryStage.getIcons().add(APPLICATION_ICON);
primaryStage.setResizable(true);
primaryStage.setMaximized(ClientPropertiesController.getPropertyAsBoolean(Property.MAXIMIZED));
primaryStage.setOnCloseRequest(close -> {
controller.onClose();
ClientPropertiesController.setProperty(Property.MAXIMIZED, primaryStage.isMaximized());
});
primaryStage.show();
if (ClientPropertiesController.getPropertyAsBoolean(Property.SHOW_CHANGELOG)
&& ClientPropertiesController.getPropertyAsBoolean(Property.CHANGELOG_ENABLED)) {
// Since the changelog has been shown after this update, it shall not be shown again,
// unless there is another update
ClientPropertiesController.setProperty(Property.SHOW_CHANGELOG, false);
final TrayNotification trayNotification = new TrayNotificationBuilder()
.type(NotificationTypeImplementations.INFORMATION)
.title(Client.lang.getString("updated"))
.message(Client.lang.getString("clickForChangelog"))
.animation(Animations.SLIDE).build();
trayNotification.setOnMouseClicked(__ -> {
OSUtility.browse("https://github.com/Bios-Marcel/ServerBrowser/releases/latest");
trayNotification.dismiss();
});
trayNotification.showAndWait();
}
}
示例15: start
import javafx.stage.Stage; //导入方法依赖的package包/类
@Override
public void start(Stage primaryStage) throws IOException {
Module module = new ETUmulatorModule();
Injector injector = Guice.createInjector(module);
primaryStage.setTitle("ETUmulator");
ClassLoader classLoader = ETUmulator.class.getClassLoader();
FXMLLoader fxmlLoader = new FXMLLoader(classLoader.getResource("fxml/ETUmulator.fxml"));
fxmlLoader.setControllerFactory(injector::getInstance);
Parent root = (Parent) fxmlLoader.load();
Scene scene = new Scene(root);
primaryStage.setScene(scene);
primaryStage.show();
injector.injectMembers(this);
fileMenuController.setWindow(primaryStage.getOwner());
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
processor.stop();
}
});
primaryStage.setOnCloseRequest((event) -> {
processor.terminate();
primaryStage.close();
});
}