List of usage examples for javafx.application Platform exit
public static void exit()
From source file:application.Main.java
public void createTrayIcon(final Stage stage) { // if the operating system // supports the system tray if (SystemTray.isSupported()) { // get the SystemTray instance SystemTray tray = SystemTray.getSystemTray(); // load an image java.awt.Image image = null; try {/*from w w w . j a va 2 s.c om*/ // File file = new File(iconLocation); // image = ImageIO.read(file); URL urlIcon = Main.class.getResource(iconLocation); image = ImageIO.read(urlIcon); } catch (IOException ex) { System.out.println(ex); } stage.setOnCloseRequest(new EventHandler<WindowEvent>() { @Override public void handle(WindowEvent t) { hide(stage); } }); // create an action listener to listen for default action executed on the tray icon final ActionListener closeListener = new ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent e) { Platform.runLater(new Runnable() { @Override public void run() { stage.close(); controller.terminate(); // // fileWatcher.setTerminateWatching(Boolean.TRUE); System.out.println(applicationTitle + " terminated!"); Platform.exit(); System.exit(0); } }); } }; ActionListener showListener = new ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent e) { Platform.runLater(new Runnable() { @Override public void run() { stage.show(); } }); } }; // create a pop-up menu PopupMenu popupMenu = new PopupMenu(); MenuItem nameItem = new MenuItem(applicationTitle); nameItem.addActionListener(showListener); popupMenu.add(nameItem); popupMenu.addSeparator(); MenuItem showItem = new MenuItem("Show"); showItem.addActionListener(showListener); popupMenu.add(showItem); MenuItem closeItem = new MenuItem("Close"); closeItem.addActionListener(closeListener); popupMenu.add(closeItem); /// ... add other menu items // construct a TrayIcon, scaling the image to 16x16 (the default dimensions of a tray icon) trayIcon = new TrayIcon(image.getScaledInstance(24, 24, Image.SCALE_DEFAULT), applicationTitle, popupMenu); // set the TrayIcon properties trayIcon.addActionListener(showListener); // add the tray image try { tray.add(trayIcon); } catch (AWTException e) { System.err.println(e); } } }
From source file:eu.over9000.skadi.ui.MainWindow.java
@Override public void start(final Stage stage) throws Exception { this.stage = stage; this.detailPane = new ChannelDetailPane(this); this.bp = new BorderPane(); this.sp = new SplitPane(); this.sb = new StatusBar(); this.setupTable(); this.setupToolbar(stage); this.sp.getItems().add(this.table); this.bp.setTop(this.tb); this.bp.setCenter(this.sp); this.bp.setBottom(this.sb); final Scene scene = new Scene(this.bp, 1280, 720); scene.getStylesheets().add(this.getClass().getResource("/styles/copyable-label.css").toExternalForm()); scene.setOnDragOver(event -> {// ww w. j a v a 2 s .co m final Dragboard d = event.getDragboard(); if (d.hasUrl() || d.hasString()) { event.acceptTransferModes(TransferMode.COPY); } else { event.consume(); } }); scene.setOnDragDropped(event -> { final Dragboard d = event.getDragboard(); boolean success = false; if (d.hasUrl()) { final String user = StringUtil.extractUsernameFromURL(d.getUrl()); if (user != null) { success = this.channelHandler.addChannel(user, this.sb); } else { this.sb.setText("dragged url is no twitch stream"); } } else if (d.hasString()) { success = this.channelHandler.addChannel(d.getString(), this.sb); } event.setDropCompleted(success); event.consume(); }); stage.setTitle("Skadi"); stage.getIcons().add(new Image(this.getClass().getResourceAsStream("/icons/skadi.png"))); stage.setScene(scene); stage.show(); stage.iconifiedProperty().addListener((obs, oldV, newV) -> { if (this.currentState.isMinimizeToTray()) { if (newV) { stage.hide(); } } }); stage.setOnCloseRequest(event -> Platform.exit()); this.bindColumnWidths(); }
From source file:jobhunter.gui.FXMLController.java
@FXML void quit(ActionEvent event) { if (ApplicationState.changesPending()) { Action response = DialogFactory.quit(this.parent); // Cancel so no action is done if (response.equals(Dialog.Actions.CANCEL)) return; // Don't save changes, then quit if (response.equals(Dialog.Actions.NO)) { Platform.exit(); return; }//from w w w .ja v a2s. c om // Lets save and then quit save(null); Platform.exit(); } else { Platform.exit(); } }
From source file:jviewmda.JViewMda.java
private void on_file_exit() { Platform.exit(); }
From source file:com.loop81.fxcomparer.FXComparerController.java
/** Called from the "Exit" menu item, will close the application. */ @FXML protected void onMenuExit(ActionEvent event) { event.consume(); Platform.exit(); }
From source file:com.mycompany.songbitmaven.RecommendationController.java
@FXML public void close(ActionEvent e) { Platform.exit(); }
From source file:io.uploader.drive.DriveUploader.java
@Override public void start(final Stage stage) throws Exception { Preconditions.checkNotNull(stage);/*from ww w .ja v a 2 s . com*/ try { stage.onCloseRequestProperty().set(new EventHandler<WindowEvent>() { public void handle(WindowEvent e) { logger.info("Close request"); if (Response.NO == MessageDialogs.showConfirmDialog(stage, "Are you sure you want to close the application?", "Confirmation")) { e.consume(); return; } appEvent.exit(); Platform.exit(); // TODO: // Investigate why when we shutdown the authentication service // before the end of the process, the app hangs after closing the main window... // http://stackoverflow.com/questions/4425350/how-to-terminate-a-thread-blocking-on-socket-io-operation-instantly //if (client == null) { System.exit(0); //} } }); final List<Integer> logoSizeList = Arrays.asList(16, 32, 64, 128, 256, 512); final String logoNameBase = "DriveUploader"; final String logoNameExt = ".png"; for (Integer size : logoSizeList) { StringBuilder logoName = new StringBuilder(); logoName.append(logoNameBase); logoName.append(size); logoName.append(logoNameExt); Image logo = new Image(getClass().getResourceAsStream("/images/" + logoName)); stage.getIcons().add(logo); } //final Browser browser = new SimpleBrowser (new Stage (), null) ; final Browser browser = new SimpleBrowserImpl(stage, null); authorize(browser, new Callback<Credential>() { @Override public void onSuccess(Credential result) { logger.info("Received credential"); client = new Drive.Builder(httpTransport, JSON_FACTORY, result) .setApplicationName(APPLICATION_NAME).build(); Configuration.INSTANCE.setCredential(result); //browser.close () ; try { MainWindow mainWindow = new MainWindow(client, stage, appEvent, Configuration.INSTANCE); mainWindow.show(); } catch (IOException e) { logger.error("Error occurred while creating the main window", e); Platform.exit(); } } @Override public void onFailure(Throwable cause) { logger.error("Error occurred while authenticating", cause); Platform.exit(); } }); } catch (Exception e) { Platform.exit(); throw e; } }
From source file:de.micromata.mgc.javafx.launcher.gui.AbstractMainWindow.java
@FXML private void closeApplication(ActionEvent event) { if (model != null) { model.stop();//from www. ja v a 2 s .c o m } Platform.exit(); System.exit(0); // NOSONAR System.exit(...) and Runtime.getRuntime().exit(...) should not be called" Main app exit. }
From source file:investiagenofx2.view.InvestiaGenOFXController.java
@FXML void handleMnuQuit(ActionEvent event) { InvestiaGenOFX.getWebClient().close(); PropertiesInit.setInvestiaURL(txt_investiaURL.getText()); PropertiesInit.setLastGenUsedDate(dtp_lastDate.getValue().toString()); PropertiesInit.setClientNumList(cbo_clientNum.getItems().toString().replace("[", "").replace("]", "")); PropertiesInit.setProperties();/*from w w w. j av a2 s.c o m*/ Platform.exit(); System.exit(0); }
From source file:view.EditorView.java
@FXML void menuItemCloseOnAction(@SuppressWarnings("unused") ActionEvent event) { Platform.exit(); }