List of usage examples for javafx.stage Stage getIcons
public final ObservableList<Image> getIcons()
From source file:net.rptools.tokentool.client.TokenTool.java
@Override public void start(Stage primaryStage) throws IOException { stage = primaryStage;// ww w . ja v a2s . co m setUserAgentStylesheet(STYLESHEET_MODENA); // Setting the style back to the new Modena FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource(AppConstants.TOKEN_TOOL_FXML), ResourceBundle.getBundle(AppConstants.TOKEN_TOOL_BUNDLE)); root = fxmlLoader.load(); tokentool_Controller = (TokenTool_Controller) fxmlLoader.getController(); Scene scene = new Scene(root); primaryStage.setTitle(I18N.getString("TokenTool.stage.title")); primaryStage.getIcons().add(new Image(getClass().getResourceAsStream(AppConstants.TOKEN_TOOL_ICON))); primaryStage.setScene(scene); primaryStage.widthProperty().addListener((obs, oldVal, newVal) -> { if (Double.isNaN(oldVal.doubleValue())) return; deltaX += newVal.doubleValue() - oldVal.doubleValue(); // Only adjust on even width adjustments if (deltaX > 1 || deltaX < -1) { if (deltaX % 2 == 0) { tokentool_Controller.updatePortraitLocation(deltaX, 0); deltaX = 0; } else { tokentool_Controller.updatePortraitLocation(deltaX - 1, 0); deltaX = 1; } } }); primaryStage.heightProperty().addListener((obs, oldVal, newVal) -> { if (Double.isNaN(oldVal.doubleValue())) return; deltaY += newVal.doubleValue() - oldVal.doubleValue(); // Only adjust on even width adjustments if (deltaY > 1 || deltaY < -1) { if (deltaY % 2 == 0) { tokentool_Controller.updatePortraitLocation(0, deltaY); deltaY = 0; } else { tokentool_Controller.updatePortraitLocation(0, deltaY - 1); deltaY = 1; } } }); primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() { @Override public void handle(WindowEvent event) { tokentool_Controller.exitApplication(); } }); // Load all the overlays into the treeview tokentool_Controller.updateOverlayTreeview(overlayTreeItems); // Restore saved settings AppPreferences.restorePreferences(tokentool_Controller); // Add recent list to treeview tokentool_Controller.updateOverlayTreeViewRecentFolder(true); // Set the Overlay Options accordion to be default open view tokentool_Controller.expandOverlayOptionsPane(true); primaryStage.show(); // Finally, update token preview image after everything is done loading Platform.runLater(() -> tokentool_Controller.updateTokenPreviewImageView()); }
From source file:com.antonjohansson.svncommit.SvnCommitApplication.java
private void configure(Stage stage, String application, File path, Configuration configuration) { Module applicationModule = new ApplicationModule(); Module utilityModule = new UtilityModule(); Module configurationModule = (binder) -> { binder.bind(File.class).toInstance(path); binder.bind(Configuration.class).toInstance(configuration); };//from w ww .j a v a 2 s. co m Injector injector = Guice.createInjector(applicationModule, utilityModule, configurationModule); Worker worker = injector.getInstance(Worker.class); Controller controller = injector.getInstance(Key.get(Controller.class, named(application))); controller.initialize(); View view = controller.getView(); stage.setScene(new Scene(view.getParent())); stage.setTitle("svn-commit"); stage.setWidth(1200); stage.setHeight(400); stage.getIcons().add(new Image("svn.png")); stage.setOnCloseRequest(e -> worker.shutdown()); stage.show(); }
From source file:org.pdfsam.App.java
@Override public void start(Stage primaryStage) { STOPWATCH.start();/*www . j a va 2s . c o m*/ LOG.info(DefaultI18nContext.getInstance().i18n("Starting pdfsam")); List<String> styles = (List<String>) ApplicationContextHolder.getContext().getBean("styles"); Map<String, Image> logos = ApplicationContextHolder.getContext().getBeansOfType(Image.class); MainPane mainPane = ApplicationContextHolder.getContext().getBean(MainPane.class); NotificationsContainer notifications = ApplicationContextHolder.getContext() .getBean(NotificationsContainer.class); StackPane main = new StackPane(); StackPane.setAlignment(notifications, Pos.BOTTOM_RIGHT); StackPane.setAlignment(mainPane, Pos.TOP_LEFT); main.getChildren().addAll(mainPane, notifications); Scene scene = new Scene(main); scene.getStylesheets().addAll(styles); primaryStage.setScene(scene); primaryStage.getIcons().addAll(logos.values()); primaryStage.setTitle(ApplicationContextHolder.getContext().getBean("appName", String.class)); scene.getAccelerators().put(new KeyCodeCombination(KeyCode.L, KeyCombination.SHORTCUT_DOWN), () -> eventStudio().broadcast(new ShowStageRequest(), "LogStage")); primaryStage.show(); eventStudio().add(new TitleController(primaryStage)); requestCheckForUpdateIfNecessary(); eventStudio().addAnnotatedListeners(this); STOPWATCH.stop(); LOG.info(DefaultI18nContext.getInstance().i18n("Started in {0}", DurationFormatUtils.formatDurationWords(STOPWATCH.getTime(), true, true))); }
From source file:com.cdd.bao.editor.EditSchema.java
public EditSchema(Stage stage) { this.stage = stage; if (MainApplication.icon != null) stage.getIcons().add(MainApplication.icon); menuBar = new MenuBar(); menuBar.setUseSystemMenuBar(true);/*from w w w. ja v a 2 s . co m*/ menuBar.getMenus().add(menuFile = new Menu("_File")); menuBar.getMenus().add(menuEdit = new Menu("_Edit")); menuBar.getMenus().add(menuValue = new Menu("_Value")); menuBar.getMenus().add(menuView = new Menu("Vie_w")); createMenuItems(); treeRoot = new TreeItem<>(new Branch(this)); treeView = new TreeView<>(treeRoot); treeView.setEditable(true); treeView.setCellFactory(p -> new HierarchyTreeCell()); treeView.getSelectionModel().selectedItemProperty().addListener((observable, oldVal, newVal) -> { if (oldVal != null) pullDetail(oldVal); if (newVal != null) pushDetail(newVal); }); treeView.focusedProperty() .addListener((val, oldValue, newValue) -> Platform.runLater(() -> maybeUpdateTree())); detail = new DetailPane(this); StackPane sp1 = new StackPane(), sp2 = new StackPane(); sp1.getChildren().add(treeView); sp2.getChildren().add(detail); splitter = new SplitPane(); splitter.setOrientation(Orientation.HORIZONTAL); splitter.getItems().addAll(sp1, sp2); splitter.setDividerPositions(0.4, 1.0); progBar = new ProgressBar(); progBar.setMaxWidth(Double.MAX_VALUE); root = new BorderPane(); root.setTop(menuBar); root.setCenter(splitter); root.setBottom(progBar); BorderPane.setMargin(progBar, new Insets(2, 2, 2, 2)); Scene scene = new Scene(root, 1000, 800, Color.WHITE); stage.setScene(scene); treeView.setShowRoot(false); treeRoot.getChildren().add(treeTemplate = new TreeItem<>(new Branch(this, "Template"))); treeRoot.getChildren().add(treeAssays = new TreeItem<>(new Branch(this, "Assays"))); treeTemplate.setExpanded(true); treeAssays.setExpanded(true); rebuildTree(); Platform.runLater(() -> treeView.getFocusModel().focus(treeView.getSelectionModel().getSelectedIndex())); // for some reason it defaults to not the first item stage.setOnCloseRequest(event -> { if (!confirmClose()) event.consume(); }); updateTitle(); // loading begins in a background thread, and is updated with a status bar Vocabulary.Listener listener = new Vocabulary.Listener() { public void vocabLoadingProgress(Vocabulary vocab, float progress) { Platform.runLater(() -> { progBar.setProgress(progress); if (vocab.isLoaded()) root.getChildren().remove(progBar); }); } public void vocabLoadingException(Exception ex) { ex.printStackTrace(); } }; Vocabulary.globalInstance(listener); }
From source file:view.EditorView.java
@Override public void start(Stage primaryStage) throws Exception { Platform.setImplicitExit(true);//from w ww. jav a2 s . c o m bundle = ResourceBundle.getBundle("view.strings"); stage = primaryStage; try { Parent root = FXMLLoader.load(getClass().getResource("EditorMain.fxml"), bundle); Scene scene = new Scene(root); scene.getStylesheets().add(getClass().getResource("EditorMain.css").toExternalForm()); primaryStage.setMinWidth(scene.getRoot().minWidth(0) + 70); primaryStage.setMinHeight(scene.getRoot().minHeight(0) + 70); primaryStage.setScene(scene); // Set Icon primaryStage.getIcons().add(new Image(MainWindow.class.getResourceAsStream("icon.png"))); primaryStage.show(); } catch (Exception e) { FOKLogger.log(MainWindow.class.getName(), Level.SEVERE, "An error occurred", e); } }
From source file:genrsa.GenRSAController.java
/** * Muestra por pantalla la informacin relativa a genRSA * @param event // w w w. j av a2 s . c o m */ public void aboutGenRSA(ActionEvent event) { Stage stage; FXMLLoader fxmlLoader; Parent root; try { stage = new Stage(); fxmlLoader = new FXMLLoader(getClass().getResource("/About/About.fxml")); root = fxmlLoader.load(); Scene scene = new Scene(root); stage.initModality(Modality.APPLICATION_MODAL); stage.initOwner(this.unitsD.getScene().getWindow()); stage.setResizable(false); stage.getIcons().add(new Image(GenRSAController.class.getResourceAsStream("/allImages/genRSA.png"))); stage.setTitle("Acerca de genRSA v2.1"); stage.setScene(scene); stage.show(); } catch (IOException ex) { //no pongo mensaje de error, porque no se puede dar el caso } }
From source file:com.bekwam.mavenpomupdater.Main.java
@Override public void start(Stage primaryStage) throws Exception { ////w w w . ja v a 2s . c o m // handle command line options // Application.Parameters params = getParameters(); List<String> unnamedList = params.getUnnamed(); Options options = new Options(); options.addOption("help", false, "Print this message"); options.addOption("hidpi", false, "Use high-DPI scaling"); CommandLineParser p = new BasicParser(); CommandLine cmd = p.parse(options, unnamedList.toArray(new String[0])); HelpFormatter formatter = new HelpFormatter(); if (cmd.hasOption("help")) { if (log.isDebugEnabled()) { log.debug("[START] running as help command"); } formatter.printHelp("Main", options); return; } AbstractModule module = null; if (runningAsJNLP()) { if (log.isInfoEnabled()) { log.info("using jnlp module and jnlp favorites store"); } module = new MPUJNLPModule(); } else { if (log.isInfoEnabled()) { log.info("using standalone module and in-memory favorites store"); } module = new MPUStandaloneModule(); } // // setup google guice // final Injector injector = Guice.createInjector(module); BuilderFactory builderFactory = new JavaFXBuilderFactory(); Callback<Class<?>, Object> guiceControllerFactory = clazz -> injector.getInstance(clazz); // // setup icons // primaryStage.getIcons().add(new Image("images/mpu_icon_64.png")); // // load fxml and wire controllers // FXMLLoader mainViewLoader = new FXMLLoader(getClass().getResource("mavenpomupdater.fxml"), null, builderFactory, guiceControllerFactory); Parent mainView = mainViewLoader.load(); MainViewController mainViewController = mainViewLoader.getController(); FXMLLoader alertViewLoader = new FXMLLoader(getClass().getResource("alert.fxml"), null, builderFactory, guiceControllerFactory); Parent alertView = alertViewLoader.load(); // // i'm continuing this manual wiring to 1) accommodate a potential // bi-directional reference problem and 2) to make sure that guice // doesn't return different object for the main -> alert and alert -> // main dependency injections // final AlertController alertController = alertViewLoader.getController(); mainViewController.alertController = alertController; alertController.mainViewControllerRef = new WeakReference<MainViewController>(mainViewController); // // add FlowPane, StackPane objects (defined in program and outside of // FXML) // final FlowPane fp = new FlowPane(); fp.setAlignment(Pos.CENTER); fp.getChildren().add(alertView); fp.getStyleClass().add("alert-background-pane"); final StackPane sp = new StackPane(); sp.getChildren().add(fp); // initially hide the alert sp.getChildren().add(mainView); // // setup scene // Scene scene = new Scene(sp); scene.getStylesheets().add("com/bekwam/mavenpomupdater/mpu.css"); scene.setOnKeyPressed(keyEvent -> { KeyCode key = keyEvent.getCode(); if (key == KeyCode.ESCAPE && (sp.getChildren().get(1) == fp)) { if (log.isDebugEnabled()) { log.debug("[ESCAPE]"); } alertController.action(); } }); // // setup stage // primaryStage.setTitle("Maven POM Version Updater"); primaryStage.setScene(scene); if (cmd.hasOption("hidpi")) { if (log.isInfoEnabled()) { log.info("running in Hi-DPI display mode"); } primaryStage.setWidth(2560.0); primaryStage.setHeight(1440.0); primaryStage.setMinWidth(1920.0); primaryStage.setMinHeight(1080.0); mainViewController.adjustForHiDPI(); } else { if (log.isInfoEnabled()) { log.info("running in normal display mode"); } primaryStage.setWidth(1280.0); primaryStage.setHeight(800.0); primaryStage.setMinWidth(1024.0); primaryStage.setMinHeight(768.0); } primaryStage.show(); }
From source file:io.uploader.drive.DriveUploader.java
@Override public void start(final Stage stage) throws Exception { Preconditions.checkNotNull(stage);//from w w w. j a v a 2 s . c o m 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: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 ww. java2 s. com 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:nl.mvdr.umvc3replayanalyser.gui.ErrorMessagePopup.java
/** * Handles an exception that caused program startup to fail, by showing an error message to the user. * //from w w w.j a v a2 s . c o m * @param title * title for the dialog * @param errorMessage * error message * @param stage * stage in which to show the error message * @param exception * exception that caused the error */ public static void show(String title, String errorMessage, final Stage stage, Exception exception) { log.info("Showing error message dialog to indicate that startup failed."); // Create the error dialog programatically without relying on FXML, to minimize the chances of further failure. stage.setTitle(title); // Error message text. Text text = new Text(errorMessage); // Text area containing the stack trace. Not visible by default. String stackTrace; if (exception != null) { stackTrace = ExceptionUtils.getStackTrace(exception); } else { stackTrace = "No more details available."; } final TextArea stackTraceArea = new TextArea(stackTrace); stackTraceArea.setEditable(false); stackTraceArea.setVisible(false); // Details button for displaying the stack trace. Button detailsButton = new Button(); detailsButton.setText("Details"); detailsButton.setOnAction(new EventHandler<ActionEvent>() { /** {@inheritDoc} */ @Override public void handle(ActionEvent event) { log.info("User clicked Details."); stackTraceArea.setVisible(!stackTraceArea.isVisible()); } }); // OK button for closing the dialog. Button okButton = new Button(); okButton.setText("OK"); okButton.setOnAction(new EventHandler<ActionEvent>() { /** {@inheritDoc} */ @Override public void handle(ActionEvent event) { log.info("User clicked OK, closing the dialog."); stage.close(); } }); // Horizontal box containing the buttons, to make sure they are always centered. HBox buttonsBox = new HBox(5); buttonsBox.getChildren().add(detailsButton); buttonsBox.getChildren().add(okButton); buttonsBox.setAlignment(Pos.CENTER); // Layout constraints. AnchorPane.setTopAnchor(text, Double.valueOf(5)); AnchorPane.setLeftAnchor(text, Double.valueOf(5)); AnchorPane.setRightAnchor(text, Double.valueOf(5)); AnchorPane.setTopAnchor(stackTraceArea, Double.valueOf(31)); AnchorPane.setLeftAnchor(stackTraceArea, Double.valueOf(5)); AnchorPane.setRightAnchor(stackTraceArea, Double.valueOf(5)); AnchorPane.setBottomAnchor(stackTraceArea, Double.valueOf(36)); AnchorPane.setLeftAnchor(buttonsBox, Double.valueOf(5)); AnchorPane.setRightAnchor(buttonsBox, Double.valueOf(5)); AnchorPane.setBottomAnchor(buttonsBox, Double.valueOf(5)); AnchorPane root = new AnchorPane(); root.getChildren().addAll(text, stackTraceArea, buttonsBox); stage.setScene(new Scene(root)); // Use a standard program icon if possible. try { stage.getIcons().add(Icons.get().getRandomPortrait()); } catch (IllegalStateException e) { log.warn("Failed to load icon for error dialog; proceeding with default JavaFX icon.", e); } stage.show(); // Default size should also be the minimum size. stage.setMinWidth(stage.getWidth()); stage.setMinHeight(stage.getHeight()); log.info("Error dialog displayed."); }