List of usage examples for javafx.application Platform exit
public static void exit()
From source file:com.toyota.carservice.controller.SwitchController.java
@Override public void initialize(URL url, ResourceBundle rb) { Platform.runLater(() -> {/*from w w w. j a v a 2 s. co m*/ new FadeInTransition(btnInformasiService).play(); new FadeInTransition(btnKelolaData).play(); lblClose.setOnMouseClicked((MouseEvent event) -> { Platform.exit(); System.exit(0); }); }); }
From source file:com.esri.geoevent.test.performance.ui.OrchestratorUI.java
@Override public void start(Stage primaryStage) { Parameters parameters = getParameters(); Map<String, String> args = parameters.getNamed(); String modeStr = args.get("mode"); if (modeStr == null) { modeStr = "Orchestrator"; }// w ww . j a v a2s . c om if (StringUtils.isEmpty(modeStr)) { System.err.print(UIMessages.getMessage("STARTUP_ERROR_MODE_NULL") + UIMessages.getMessage("STARTUP_MODE_TYPES", Mode.getAllowableValues())); Platform.exit(); System.exit(0); return; } Mode mode = Mode.fromValue(modeStr); String fxmlFile = ""; Object controller = null; switch (mode) { case Orchestrator: fxmlFile = "Orchestrator.fxml"; //controller = new OrchestratorController(); break; default: System.err.print(UIMessages.getMessage("STARTUP_ERROR_MODE_UNKNOWN", mode) + UIMessages.getMessage("STARTUP_MODE_TYPES", Mode.getAllowableValues())); Platform.exit(); System.exit(0); return; } Platform.setImplicitExit(true); try { FXMLLoader loader = new FXMLLoader(getClass().getResource(fxmlFile)); if (controller != null) { loader.setController(controller); } Parent parent = (Parent) loader.load(); Scene scene = new Scene(parent); // set the stage on the orchestrator if (loader.getController() instanceof OrchestratorController) { OrchestratorController orchestratorController = loader.getController(); orchestratorController.setStage(primaryStage); } primaryStage.setOnCloseRequest(new AppCloser()); primaryStage.setTitle(UIMessages.getMessage("UI_TITLE", mode)); primaryStage.setScene(scene); primaryStage.show(); OrchestratorUI.primaryStage = primaryStage; } catch (IOException e) { e.printStackTrace(); } }
From source file:gmailclientfx.controllers.LoginController.java
public void btnLogin_click(ActionEvent e) { if (!txtEmail.getText().equals("")) { String email = txtEmail.getText(); if (EmailValidator.getInstance().isValid(email)) { User user = User.getUserByEmail(email); if (!(user == null)) { try { GmailClient.setRefreshToken(user.getRefreshToken()); GmailClient.refreshAccessToken(); Parent loginStage = txtEmail.getParent(); loginStage.getScene().getWindow().hide(); Parent root;/*from w w w . j a va 2 s . c om*/ root = FXMLLoader .load(getClass().getClassLoader().getResource("gmailclientfx/views/Home.fxml")); Stage stage = new Stage(); stage.setTitle("Home"); stage.setOnCloseRequest(new EventHandler<WindowEvent>() { @Override public void handle(WindowEvent e) { Platform.exit(); System.exit(0); } }); stage.setScene(new Scene(root)); stage.show(); } catch (IOException ex) { Logger.getLogger(LoginController.class.getName()).log(Level.SEVERE, null, ex); } } else { try { GmailClient.authorizeUser(); String noviEmail = GmailClient.getEmail(); String noviRefreshToken = GmailClient.getRefreshToken(); User u = User.getUserByEmail(noviEmail); if (u == null) { User.unesiUseraUBazu(new User(noviEmail, noviRefreshToken)); } Parent loginStage = txtEmail.getParent(); loginStage.getScene().getWindow().hide(); Parent root; root = FXMLLoader .load(getClass().getClassLoader().getResource("gmailclientfx/views/Home.fxml")); Stage stage = new Stage(); stage.setTitle("Home"); stage.setScene(new Scene(root)); stage.setOnCloseRequest(new EventHandler<WindowEvent>() { @Override public void handle(WindowEvent e) { Platform.exit(); System.exit(0); } }); stage.show(); } catch (IOException ex) { Logger.getLogger(LoginController.class.getName()).log(Level.SEVERE, null, ex); } } } else { lblStatusMsg.setText("Uneseni email nije validan!"); } } else { lblStatusMsg.setText("Unesite email!"); } }
From source file:dtv.DTVEdit.java
@Override public void start(Stage primaryStage) throws Exception { notifyPreloader(new Preloader.StateChangeNotification(Preloader.StateChangeNotification.Type.BEFORE_START)); primaryStage.setTitle("DTV Edit"); primaryStage.getIcons().add(new Image(getClass().getResourceAsStream("/app_icon.png"))); AnchorPane mainView = (AnchorPane) load("/dtv/view/FXMLMain.fxml"); // Show the scene containing the root layout. Scene scene = new Scene(mainView); primaryStage.setScene(scene);/*from w ww . j a v a 2 s . co m*/ primaryStage.setResizable(false); primaryStage.setOnCloseRequest(e -> Platform.exit()); // set scss style /* String css = getClass().getResource("/myStyle.css").toExternalForm(); scene.getStylesheets().clear(); scene.getStylesheets().add(css); */ primaryStage.show(); }
From source file:com.loyalty.controllers.DashboardController.java
@Override public void initialize(URL url, ResourceBundle rb) { try {//w ww . j av a 2 s . com kioskDTO = getService().activate(); getScheduledExecutorService().scheduleAtFixedRate(this::renewPromotions, 0, 10, TimeUnit.SECONDS); animate(); } catch (KioskException ke) { getDialogManager().showInformation(ke.getMessage()); } catch (IOException ioe) { getDialogManager().showInformation( "Client Application could not login to server. Check Your credentials and Kiosk License."); Platform.exit(); } // //ipAddress = new IPAddress().getIPAddress(); // HashMap<String, String> params = new HashMap<String, String>(); // params.put("ip", ipAddress); // params.put("status", ""); // response = new AppHelper().performPostCall(KIOSK_REGISTER_URL, params); // try { // JSONObject jsonObject = new JSONObject(response); // String msg = jsonObject.getString("msg"); // System.out.println(msg); // } catch (JSONException ex) { // ex.printStackTrace(); // } // // response_promotion = new AppHelper().performPostCall(GET_PROMOTION_OFFER_URL, params); // System.err.println(response_promotion); // if (response_promotion != null) { // try { // JSONArray jaaraa = new JSONArray(response_promotion); // // for (int i = 0; i < jaaraa.length(); i++) { // JSONObject object = jaaraa.getJSONObject(0); // String offername = object.getString("offername"); // String promotionname = object.getString("promotionname"); // String description = object.getString("description"); // String expire = object.getString("expire"); // //JSONObject JOBJ = new JSONObject(response_promotion[0]); // // System.out.println("parwez" + aa); // // } // lbl_promotion.setText(promotionname + " and " + offername + " be hurry offer valid till " + expire); // lbl_promotion.setStyle("-fx-background-color: #DF013A;-fx-background-radius: 10 10 10 10;-fx-height:90px;"); // TranslateTransition transition = TranslateTransitionBuilder.create() // .duration(new Duration(7500)) // .node(lbl_promotion) // .interpolator(Interpolator.LINEAR) // .cycleCount(Timeline.INDEFINITE) // .build(); // // GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); // int width = 1; // //gd.getDisplayMode().getWidth(); // // transition.setFromX(width); // transition.setToX(-width); // transition.play(); // // } catch (JSONException ex) { // Logger.getLogger(DashboardController.class.getName()).log(Level.SEVERE, null, ex); // } // } else { // } System.out.println("initialized"); }
From source file:org.dataconservancy.packaging.gui.App.java
public void start(Stage stage) throws Exception { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "classpath*:org/dataconservancy/config/applicationContext.xml", "classpath*:org/dataconservancy/packaging/tool/ser/config/applicationContext.xml", "classpath*:applicationContext.xml"); // min supported size is 800x600 stage.setMinWidth(800);/*w w w .j av a 2 s . c o m*/ stage.setMinHeight(550); Factory factory = (Factory) context.getBean("factory"); factory.setStage(stage); Font.loadFont(App.class.getResource("/fonts/OpenSans-Regular.ttf").toExternalForm(), 14); Font.loadFont(App.class.getResource("/fonts/OpenSans-Italic.ttf").toExternalForm(), 14); Font.loadFont(App.class.getResource("/fonts/OpenSans-Bold.ttf").toExternalForm(), 14); Configuration config = factory.getConfiguration(); CmdLineParser parser = new CmdLineParser(config); try { List<String> raw = getParameters().getRaw(); parser.parseArgument(raw.toArray(new String[raw.size()])); } catch (CmdLineException e) { System.out.println(e.getMessage()); log.error(e.getMessage()); Platform.exit(); return; } Controller controller = factory.getController(); controller.setApplicationHostServices(getHostServices()); controller.startApp(); // Default size to 800x800, but shrink if screen is too small double sceneHeight = 800; Rectangle2D screen = Screen.getPrimary().getVisualBounds(); if (screen.getHeight() < 800) { sceneHeight = screen.getHeight() - 50; if (sceneHeight < 550) sceneHeight = 550; } Scene scene = new Scene(controller.asParent(), 800, sceneHeight); scene.getStylesheets().add("/css/app.css"); stage.getIcons().add(new Image("/images/DCPackageTool-icon.png")); stage.setTitle("DC Package Tool"); stage.setScene(scene); stage.show(); }
From source file:org.nmrfx.processor.gui.MainApp.java
public static void removeStage(Stage stage) { synchronized (stages) { stages.remove(stage);//from w ww . j a v a2 s .c o m if (stages.isEmpty()) { Platform.exit(); System.exit(0); } } }
From source file:com.kotcrab.vis.editor.CrashReporter.java
@FXML private void handleRestart(ActionEvent event) { buttonsBox.setDisable(true); restart(); Platform.exit(); }
From source file:com.fishbeans.stream.StreamReceiver.java
public final void addOutput(byte[] data, int offset, int length) { String rawData = new String(data, offset, length); if (rawData.contains(ADB_ERRORS.FAIL_ERROR.getErrorKey())) { if (rawData.contains(ADB_ERRORS.OFFLINE_ERROR.getErrorKey())) { DeviceOffLineAlert alert = new DeviceOffLineAlert(); Optional<Boolean> result = alert.showAndWait(); if ((result.isPresent()) && result.get()) { Platform.runLater(() -> Platform.exit()); }//from w ww.jav a2s . c o m } } // ok we've got a string // if we had an unfinished line we add it. if (mUnfinishedLine != null) { rawData = mUnfinishedLine + rawData; mUnfinishedLine = null; } // now we split the lines internalStringDataBuffer.clear(); int start = 0; do { int index = rawData.indexOf('\n', start); // if \n was not found, this is an unfinished line // and we store it to be processed for the next packet if (index == -1) { mUnfinishedLine = rawData.substring(start); break; } // we found a \n, in older devices, this is preceded by a \r int newlineLength = 1; if (index > 0 && rawData.charAt(index - 1) == '\r') { index--; newlineLength = 2; } // extract the line String line = rawData.substring(start, index); if (mTrimLines) { line = line.trim(); } internalStringDataBuffer.add(line); // move start to after the \r\n we found start = index + newlineLength; } while (true); if (!internalStringDataBuffer.isEmpty()) { // at this point we've split all the lines. // make the array String[] lines = internalStringDataBuffer.toArray(new String[internalStringDataBuffer.size()]); // send for final processing for (String line : lines) { processNewLine(line); } } }
From source file:com.epitech.oliver_f.astextexls.MainClass.java
@Override public void start(Stage primaryStage) throws Exception { primaryStage.setTitle("Hello World!"); DirectoryChooser dChooser = new DirectoryChooser(); dChooser.setTitle("Choose the directory of the excel files"); File defaultDirectory = new File("c:/"); dChooser.setInitialDirectory(defaultDirectory); File selectedDirectory = dChooser.showDialog(primaryStage); StackPane root = new StackPane(); FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("Open excel 'ALL' File"); File choosenFile = fileChooser.showOpenDialog(primaryStage); launchWriteAndRead(selectedDirectory.getAbsolutePath(), choosenFile.getAbsolutePath()); //root.getChildren().add(btn); //primaryStage.setScene(new Scene(root, 300, 250)); //primaryStage.show(); Platform.exit(); }