javafx.stage.WindowEvent Java Examples
The following examples show how to use
javafx.stage.WindowEvent.
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: HelpBox.java From scenic-view with GNU General Public License v3.0 | 7 votes |
public HelpBox(final String title, final String url, final double x, final double y) { final BorderPane pane = new BorderPane(); pane.setId(StageController.FX_CONNECTOR_BASE_ID + "HelpBox"); pane.setPrefWidth(SCENE_WIDTH); pane.setPrefHeight(SCENE_HEIGHT); final ProgressWebView wview = new ProgressWebView(); wview.setPrefHeight(SCENE_HEIGHT); wview.setPrefWidth(SCENE_WIDTH); wview.doLoad(url); pane.setCenter(wview); final Scene scene = new Scene(pane, SCENE_WIDTH, SCENE_HEIGHT); stage = new Stage(); stage.setTitle(title); stage.setScene(scene); stage.getIcons().add(HELP_ICON); stage.setOnCloseRequest(new EventHandler<WindowEvent>() { @Override public void handle(final WindowEvent arg0) { DisplayUtils.showWebView(false); } }); stage.show(); }
Example #2
Source File: PopOverWrapper.java From pmd-designer with BSD 2-Clause "Simplified" License | 6 votes |
/** * This is a weird hack to preload the FXML and CSS, so that the * first opening of the popover doesn't look completely broken * (twitching and obviously being restyled). * * <p>We show the popover briefly with opacity 0, just the time for its * content graph to load. When hidden the opacity is reset to 1. */ public void doFirstLoad(Stage stage) { myPopover.ifPresent(pop -> { pop.setOpacity(0); pop.setAnimated(false); pop.show(stage, 40000, 40000); EventStreams.eventsOf(pop, WindowEvent.WINDOW_HIDDEN) .subscribeForOne(e -> pop.setOpacity(1)); Platform.runLater(() -> { pop.hide(); pop.setAnimated(true); }); }); }
Example #3
Source File: TrayDemo.java From oim-fx with MIT License | 6 votes |
@Override public void start(final Stage stage) throws Exception { enableTray(stage); GridPane grid = new GridPane(); grid.setAlignment(Pos.CENTER); grid.setHgap(20); grid.setVgap(20); grid.setGridLinesVisible(true); grid.setPadding(new Insets(25, 25, 25, 25)); Button b1 = new Button("测试1"); Button b2 = new Button("测试2"); grid.add(b1, 0, 0); grid.add(b2, 1, 1); Scene scene = new Scene(grid, 800, 600); stage.setScene(scene); stage.setOnCloseRequest(new EventHandler<WindowEvent>() { @Override public void handle(WindowEvent arg0) { stage.hide(); } }); }
Example #4
Source File: HideTaskBar.java From oim-fx with MIT License | 6 votes |
@Override public void start(final Stage stage) throws Exception { stage.initStyle(StageStyle.UTILITY); stage.setScene(new Scene(new Group(), 100, 100)); stage.setX(0); stage.setY(Screen.getPrimary().getBounds().getHeight() + 100); stage.show(); Stage app = new Stage(); app.setScene(new Scene(new Group(), 300, 200)); app.setTitle("JavaFX隐藏任务栏"); app.initOwner(stage); app.initModality(Modality.APPLICATION_MODAL); app.setOnCloseRequest(new EventHandler<WindowEvent>() { @Override public void handle(WindowEvent event) { event.consume(); stage.close(); } }); app.show(); }
Example #5
Source File: PreferencesFxPresenter.java From PreferencesFX with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ @Override public void setupEventHandlers() { // As the scene is null here, listen to scene changes and make sure // that when the window is closed, the settings are saved beforehand. // NOTE: this only applies to the main stage. When opening PreferencesFX as a Node in a new // window, the implementor needs to take care that Settings are saved by themself! // This is intentional by design to ensure that if the implementor wants to make their own // PreferencesFX dialog to not override settings in case they are discarded. preferencesFxView.sceneProperty().addListener((observable, oldScene, newScene) -> { LOGGER.trace("new Scene: " + newScene); if (newScene != null && newScene.getWindow() != null) { LOGGER.trace("addEventHandler on Window close request to save settings"); newScene.getWindow().addEventHandler(WindowEvent.WINDOW_CLOSE_REQUEST, event -> { LOGGER.trace("saveSettings because of WINDOW_CLOSE_REQUEST"); model.saveSettings(); }); } }); }
Example #6
Source File: OpcDaTrendController.java From OEE-Designer with MIT License | 6 votes |
public SplitPane initializeTrend() throws Exception { if (trendChartController == null) { // Load the fxml file and create the anchor pane FXMLLoader loader = FXMLLoaderFactory.trendChartLoader(); spTrendChart = (SplitPane) loader.getRoot(); trendChartController = loader.getController(); trendChartController.initialize(getApp()); // data provider trendChartController.setProvider(this); setImages(); getDialogStage().setOnCloseRequest((WindowEvent event1) -> { onDisconnect(); }); } return spTrendChart; }
Example #7
Source File: SideScroller.java From Project-16x16 with GNU General Public License v3.0 | 6 votes |
/** * Called by Processing after settings(). */ @Override protected PSurface initSurface() { surface = (PSurfaceFX) super.initSurface(); canvas = (Canvas) surface.getNative(); canvas.widthProperty().unbind(); // used for scaling canvas.heightProperty().unbind(); // used for scaling scene = canvas.getScene(); stage = (Stage) scene.getWindow(); stage.setTitle("Project-16x16"); stage.setResizable(false); // prevent abitrary user resize stage.setFullScreenExitHint(""); // disable fullscreen toggle hint stage.setFullScreenExitKeyCombination(KeyCombination.NO_MATCH); // prevent ESC toggling fullscreen scene.getWindow().addEventFilter(WindowEvent.WINDOW_CLOSE_REQUEST, this::closeWindowEvent); return surface; }
Example #8
Source File: FXStockChartWindow.java From Rails with GNU General Public License v2.0 | 6 votes |
@Override public void start(Stage primaryStage) { // set the stock-chart window to hide, if it has been closed Platform.setImplicitExit(false); Scene scene = new Scene(new FXStockChart(gameUIManager)); primaryStage.setTitle("Rails: Stock Chart"); primaryStage.setScene(scene); // uncheck market checkbox in the menu if the stock-chart has been closed primaryStage.addEventFilter(WindowEvent.WINDOW_CLOSE_REQUEST, event -> { gameUIManager.uncheckMenuItemBox(StatusWindow.MARKET_CMD); }); // TODO: save relocation and resizing information of the window stage = primaryStage; }
Example #9
Source File: Main.java From xJavaFxTool-spring with Apache License 2.0 | 6 votes |
@Override public void beforeInitialView(Stage stage, ConfigurableApplicationContext ctx) { super.beforeInitialView(stage, ctx); Scene scene = JavaFxViewUtil.getJFXDecoratorScene(stage, "", null, new AnchorPane()); stage.setScene(scene); stage.setOnCloseRequest(new EventHandler<WindowEvent>() { @Override public void handle(WindowEvent event) { if (AlertUtil.showConfirmAlert("确定要退出吗?")) { System.exit(0); } else { event.consume(); } } }); GUIState.setScene(scene); Platform.runLater(() -> { StageUtils.updateStageStyle(GUIState.getStage()); }); }
Example #10
Source File: ActivityStage.java From PeerWasp with MIT License | 6 votes |
private void load() { try { FXMLLoader loader = fxmlLoaderProvider.create(ViewNames.ACTIVITY_VIEW); Parent root = loader.load(); Scene scene = new Scene(root, WINDOW_WIDTH, WINDOW_HEIGHT); stage = new Stage(); stage.setTitle(WINDOW_TITLE); Collection<Image> icons = IconUtils.createWindowIcons(); stage.getIcons().addAll(icons); stage.setScene(scene); stage.addEventHandler(WindowEvent.WINDOW_CLOSE_REQUEST, new WindowCloseRequestEventHandler()); } catch (IOException e) { logger.error("Could not load activity stage: {}", e.getMessage(), e); } }
Example #11
Source File: SettingsStage.java From PeerWasp with MIT License | 6 votes |
private void load() { try { Preconditions.checkNotNull(appContext.getCurrentClientContext(), "ClientContext must not be null."); // important: use injector for client here because of client specific instances. FXMLLoader loader = fxmlLoaderProvider.create(ViewNames.SETTINGS_MAIN, appContext.getCurrentClientContext().getInjector()); Parent root = loader.load(); Scene scene = new Scene(root, WINDOW_WIDTH, WINDOW_HEIGHT); stage = new Stage(); stage.setTitle(WINDOW_TITLE); Collection<Image> icons = IconUtils.createWindowIcons(); stage.getIcons().addAll(icons); stage.setScene(scene); stage.addEventHandler(WindowEvent.WINDOW_CLOSE_REQUEST, new WindowCloseRequestEventHandler()); } catch (IOException e) { logger.error("Could not load settings stage: {}", e.getMessage(), e); } }
Example #12
Source File: MainProgramSceneController.java From Hostel-Management-System with MIT License | 6 votes |
@FXML private void activityLogButtonAction(ActionEvent event) { mainTopAnchorPane.setEffect(new BoxBlur()); passwordStage = new Stage(); passwordStage.setOnCloseRequest(new EventHandler<WindowEvent>() { @Override public void handle(WindowEvent t) { mainTopAnchorPane.effectProperty().setValue(null); } }); passwordStage.setTitle("Activity Log"); passwordStage.initModality(Modality.APPLICATION_MODAL); passwordStage.initStyle(StageStyle.UTILITY); passwordStage.setResizable(false); try { Parent passwordParent = FXMLLoader.load(getClass().getResource("activityLog.fxml")); passwordStage.setScene(new Scene(passwordParent)); passwordStage.show(); } catch (IOException ex) { } }
Example #13
Source File: StudentDetailController.java From Hostel-Management-System with MIT License | 6 votes |
@FXML private void viewPayBillAction(ActionEvent event) { MainProgramSceneController.mainTopAnchorPane.setEffect(new BoxBlur()); billStage = new Stage(); billStage.setOnCloseRequest(new EventHandler<WindowEvent>() { @Override public void handle(WindowEvent t) { MainProgramSceneController.mainTopAnchorPane.effectProperty().setValue(null); } }); billStage.setTitle("View And Pay Due Bills"); billStage.initModality(Modality.APPLICATION_MODAL); billStage.initStyle(StageStyle.UTILITY); billStage.setResizable(false); try { Parent passwordParent = FXMLLoader.load(getClass().getResource("viewPayBill.fxml")); billStage.setScene(new Scene(passwordParent)); billStage.show(); } catch (IOException ex) { } }
Example #14
Source File: Main.java From pattypan with MIT License | 6 votes |
@Override public void start(Stage stage) { Image logo = new Image(getClass().getResourceAsStream("/pattypan/resources/logo.png")); Scene scene = new Scene(new StartPane(stage), Settings.getSettingInt("windowWidth"), Settings.getSettingInt("windowHeight")); stage.setResizable(true); stage.setTitle("pattypan " + Settings.VERSION); stage.getIcons().add(logo); stage.setScene(scene); stage.show(); stage.setOnCloseRequest((WindowEvent we) -> { Settings.setSetting("windowWidth", (int) scene.getWidth() + ""); Settings.setSetting("windowHeight", (int) scene.getHeight() + ""); Settings.setSetting("version", Settings.VERSION); Settings.saveProperties(); }); }
Example #15
Source File: ExitRequestHandler.java From VocabHunter with Apache License 2.0 | 6 votes |
private boolean processCloseRequest(final WindowEvent e) { boolean isContinue = guiFileHandler.unsavedChangesCheck(); if (isContinue) { WindowSettings windowSettings = new WindowSettings(); windowSettings.setX(stage.getX()); windowSettings.setY(stage.getY()); windowSettings.setWidth(stage.getWidth()); windowSettings.setHeight(stage.getHeight()); model.getSessionModel().ifPresent(s -> saveSplitPositions(windowSettings, s)); settingsManager.setWindowSettings(windowSettings); } else { e.consume(); } return isContinue; }
Example #16
Source File: TrafficProfileDialogController.java From trex-stateless-gui with Apache License 2.0 | 6 votes |
/** * Initialize current stage */ public void init() { currentStage = (Stage) profileViewWrapper.getScene().getWindow(); currentStage.setOnShown(new EventHandler<WindowEvent>() { @Override public void handle(WindowEvent event) { currentStage.focusedProperty().addListener((ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> { if (newValue && tableView.isStreamEditingWindowOpen()) { Util.optimizeMemory(); loadStreamTable(); tableView.setStreamEditingWindowOpen(false); } }); } }); }
Example #17
Source File: SingleImageCheck.java From FakeImageDetection with GNU General Public License v3.0 | 6 votes |
@Override public void start(Stage stage) throws Exception { Parent root = FXMLLoader.load(getClass().getResource("/resources/fxml/singleimage.fxml")); Scene scene = new Scene(root); stage.resizableProperty().setValue(false); stage.setTitle("Single Image Checker"); stage.setScene(scene); stage.show(); CommonUtil.attachIcon(stage); stage.setOnCloseRequest((WindowEvent event) -> { System.exit(0); }); }
Example #18
Source File: HugoPane.java From Lipi with MIT License | 6 votes |
@FXML private void onLiveBlogServerToggle() { toggleLiveBlogServer(); updateBlogServerToggleButton(); TimedUpdaterUtil.callAfter(new CallbackVisitor() { @Override public void call() { if (!openBlogInBrowserButton.isDisabled() && !liveServerRunning) { updateBlogServerToggleButton(); ExceptionAlerter.showException(new Exception("Hugo faced a catastrophic error \n" + hugoServer.getHugoOut())); } } }); this.getScene().getWindow().setOnCloseRequest(new EventHandler<WindowEvent>() { @Override public void handle(WindowEvent event) { stopLiveBlogServer(); } }); }
Example #19
Source File: OpenLabelerController.java From OpenLabeler with Apache License 2.0 | 5 votes |
public void handleWindowEvent(WindowEvent event) { if (event.getEventType() == WindowEvent.WINDOW_SHOWN) { // Initial focus tagBoard.requestFocus(); // Open last media file/folder if (Settings.isOpenLastMedia() && Settings.recentFilesProperty.size() > 0) { File fileOrDir = new File(Settings.recentFilesProperty.get(0)); openFileOrDir(fileOrDir); } } }
Example #20
Source File: SyntaxHighlightingCodeArea.java From pmd-designer with BSD 2-Clause "Simplified" License | 5 votes |
public SyntaxHighlightingCodeArea() { // captured in the closure final EventHandler<WindowEvent> autoCloseHandler = e -> syntaxAutoRefresh.ifPresent(Subscription::unsubscribe); // handles auto shutdown of executor services // by attaching a handler to the stage responsible for the control Val.wrap(sceneProperty()) .filter(Objects::nonNull) .flatMap(Scene::windowProperty) .values() .filter(Objects::nonNull) .subscribe(c -> c.addEventHandler(WindowEvent.WINDOW_CLOSE_REQUEST, autoCloseHandler)); // prevent ALT from focusing menu addEventFilter(KeyEvent.KEY_PRESSED, e -> { if (e.isAltDown()) { e.consume(); } }); // Make TAB 4 spaces InputMap<KeyEvent> im = InputMap.consume( EventPattern.keyPressed(KeyCode.TAB), e -> replaceSelection(" ") ); Nodes.addInputMap(this, im); }
Example #21
Source File: CSSFXTesterApp.java From cssfx with Apache License 2.0 | 5 votes |
@Override public void start(Stage stage) throws Exception { fillStage(stage); stage.show(); Runnable cssfxCloseAction = CSSFX.start(); stage.getScene().getWindow() .addEventFilter(WindowEvent.WINDOW_CLOSE_REQUEST, (event) -> cssfxCloseAction.run()); }
Example #22
Source File: WaterfallPerformanceSample.java From chart-fx with Apache License 2.0 | 5 votes |
private void closeDemo(final WindowEvent evt) { if (evt.getEventType().equals(WindowEvent.WINDOW_CLOSE_REQUEST) && LOGGER.isInfoEnabled()) { LOGGER.atInfo().log("requested demo to shut down"); } if (timer != null) { timer.cancel(); timer = null; // NOPMD dataSet.stop(); } Platform.exit(); }
Example #23
Source File: ScenicViewGui.java From scenic-view with GNU General Public License v3.0 | 5 votes |
public static void show(final ScenicViewGui scenicview, final Stage stage) { final Scene scene = new Scene(scenicview.rootBorderPane); scene.getStylesheets().addAll(STYLESHEETS); stage.setScene(scene); stage.getIcons().add(APP_ICON); if (scenicview.activeStage != null && scenicview.activeStage instanceof StageControllerImpl) ((StageControllerImpl) scenicview.activeStage).placeStage(stage); stage.addEventHandler(WindowEvent.WINDOW_CLOSE_REQUEST, event -> { Runtime.getRuntime().removeShutdownHook(scenicview.shutdownHook); scenicview.close(); }); stage.show(); }
Example #24
Source File: WorkbenchTest.java From WorkbenchFX with Apache License 2.0 | 5 votes |
/** * Internal utility method for testing. * Simulates closing the stage, which fires a close request to test logic * inside of {@link Stage#setOnCloseRequest(EventHandler)}. * Using {@link FxRobot#closeCurrentWindow()} would be better, but it only works on Windows * because of its implementation, so this approach was chosen as a workaround. * @see <a href="https://github.com/TestFX/TestFX/issues/447"> * closeCurrentWindow() doesn't work headless</a> */ private void closeStage() { Stage stage = ((Stage) workbench.getScene().getWindow()); stage.fireEvent( new WindowEvent( stage, WindowEvent.WINDOW_CLOSE_REQUEST ) ); }
Example #25
Source File: Loading.java From DevToolBox with GNU Lesser General Public License v2.1 | 5 votes |
public void startMainApp(Stage ms) { try { long time = System.currentTimeMillis(); Stage stage = new Stage(); stage.setTitle(Undecorator.LOC.getString("AppName") + " " + Undecorator.LOC.getString("Version") + " 版本号:" + Undecorator.LOC.getString("VersionCode")); FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/fxml/main.fxml")); Region root = (Region) fxmlLoader.load(); final UndecoratorScene undecoratorScene = new UndecoratorScene(stage, root); stage.setOnCloseRequest((WindowEvent we) -> { we.consume(); undecoratorScene.setFadeOutTransition(); }); undecoratorScene.getStylesheets().add("/styles/main.css"); stage.setScene(undecoratorScene); stage.toFront(); stage.getIcons().add(new Image(getClass().getResourceAsStream("/skin/icon.png"))); stage.setOnShown((event) -> { new Timer().schedule(new TimerTask() { @Override public void run() { Platform.runLater(() -> { ms.close(); }); } }, 1000); }); stage.show(); ApplicationStageManager.putStageAndController(ApplicationStageManager.StateAndController.MAIN, stage, fxmlLoader.getController()); LOGGER.info("主页面加载耗时:" + (System.currentTimeMillis() - time) + "毫秒"); } catch (IOException ex) { LOGGER.error("启动主程序异常", ex); } }
Example #26
Source File: UndecoratorController.java From DevToolBox with GNU Lesser General Public License v2.1 | 5 votes |
public void close() { final Stage stage = undecorator.getStage(); Platform.runLater(() -> { stage.fireEvent(new WindowEvent(stage, WindowEvent.WINDOW_CLOSE_REQUEST)); }); }
Example #27
Source File: SideScroller.java From Project-16x16 with GNU General Public License v3.0 | 5 votes |
/** * Passes JavaFX window closed call to game. * * @param event */ private void closeWindowEvent(WindowEvent event) { try { Audio.exit(); game.exit(); } finally { stage.close(); } }
Example #28
Source File: RadialMenuItemDemo.java From RadialFx with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void start(final Stage stage) throws Exception { final RadialMenuItem item = RadialMenuItemBuilder.create().build(); item.setTranslateX(400); item.setTranslateY(300); final DemoUtil demoUtil = new DemoUtil(); demoUtil.addAngleControl("StartAngle", item.startAngleProperty()); demoUtil.addAngleControl("Length", item.lengthProperty()); demoUtil.addRadiusControl("Inner Radius", item.innerRadiusProperty()); demoUtil.addRadiusControl("Radius", item.radiusProperty()); demoUtil.addRadiusControl("Offset", item.offsetProperty()); demoUtil.addColorControl("Background", item.backgroundFillProperty()); demoUtil.addColorControl("BackgroundMouseOn", item.backgroundMouseOnFillProperty()); demoUtil.addColorControl("Stroke", item.strokeFillProperty()); demoUtil.addColorControl("StrokeMouseOn", item.strokeMouseOnFillProperty()); demoUtil.addBooleanControl("Clockwise", item.clockwiseProperty()); demoUtil.addBooleanControl("BackgroundVisible", item.backgroundVisibleProperty()); demoUtil.addBooleanControl("StrokeVisible", item.strokeVisibleProperty()); demoUtil.addGraphicControl("Graphic", item.graphicProperty()); final Group demoControls = new Group(item, demoUtil); stage.setScene(new Scene(demoControls)); stage.setOnCloseRequest(new EventHandler<WindowEvent>() { @Override public void handle(final WindowEvent arg0) { System.exit(0); } }); stage.setWidth(600); stage.setHeight(600); stage.show(); }
Example #29
Source File: EditorDemo.java From phoebus with Eclipse Public License 1.0 | 5 votes |
/** JavaFX Start */ @Override public void start(final Stage stage) { // Call ModelPlugin to trigger its static loading of config file.. ModelPlugin.logger.fine("Load configuration files"); editor = new EditorGUI(); final ObservableList<Node> toolbar = editor.getDisplayEditor().getToolBar().getItems(); toolbar.add(0, createButton(new LoadModelAction(editor))); toolbar.add(1, createButton(new SaveModelAction(editor))); toolbar.add(2, new Separator()); stage.setTitle("Editor"); stage.setWidth(1200); stage.setHeight(600); final Scene scene = new Scene(editor.getParentNode(), 1200, 600); stage.setScene(scene); EditorUtil.setSceneStyle(scene); // If ScenicView.jar is added to classpath, open it here //ScenicView.show(scene); stage.show(); // .. before the model is loaded which may then use predefined colors etc. editor.loadModel(new File(display_file)); stage.setOnCloseRequest((WindowEvent event) -> editor.dispose()); }
Example #30
Source File: BattleDetail.java From logbook-kai with MIT License | 5 votes |
/** * ウインドウを閉じる時のアクション * * @param e WindowEvent */ @Override protected void onWindowHidden(WindowEvent e) { if (this.timeline != null) { this.timeline.stop(); } }