List of usage examples for javafx.scene Scene getStylesheets
public final ObservableList<String> getStylesheets()
From source file:retsys.client.controller.LoginController.java
private Initializable replaceSceneContent(String fxml) throws Exception { URL location = getClass().getResource(fxml); FXMLLoader fxmlLoader = new FXMLLoader(); fxmlLoader.setBuilderFactory(new JavaFXBuilderFactory()); InputStream in = getClass().getResourceAsStream(fxml); Parent root;/*from ww w .j a v a2s .c om*/ fxmlLoader.setLocation(location); AnchorPane page; try { page = (AnchorPane) fxmlLoader.load(in); } finally { in.close(); } Scene scene = new Scene(page); scene.getStylesheets().add(this.getClass().getResource("/retsys/client/css/styles.css").toExternalForm()); stage.setScene(scene); stage.setFullScreen(true); //stage.sizeToScene(); return (Initializable) fxmlLoader.getController(); }
From source file:com.github.xwgou.namesurfer.fxui.JFXNameSurfer.java
@Override public void start(final Stage stage) { try {/*from www . j av a 2s . c o m*/ final ScalableContentPane scp = new ScalableContentPane(); scp.setStyle("-fx-background-color: green;"); Pane root = scp.getContentPane(); final JFXNameSurferPanel rootNode = new JFXNameSurferPanel(translator); rootNode.controller.exportButton.setDisable(disable_buttons); rootNode.controller.saveButton.setDisable(disable_buttons); root.getChildren().add(rootNode); final Scene scene = new Scene(scp, 1024, 576); scene.getStylesheets() .add(getClass().getResource("/com/github/xwgou/namesurfer/css/color.css").toExternalForm()); scp.layoutBoundsProperty().addListener((observable, oldValue, newValue) -> { double aspect_ratio = scp.getWidth() / scp.getHeight(); logger.debug(scp.getLayoutBounds().toString()); logger.debug("" + aspect_ratio); double w = 1024.0; double h = 576.0; if (aspect_ratio > 1024 / 576) w = 576 * aspect_ratio; else h = 1024 / aspect_ratio; rootNode.setPrefWidth(w); rootNode.setPrefHeight(h); }); stage.setTitle("NameSurfer"); stage.setScene(scene); stage.setFullScreen(fullscreen); stage.show(); } catch (Exception ex) { logger.error("Exception during application startup", ex); throw ex; } }
From source file:org.pdfsam.ui.news.NewsStage.java
@Inject public NewsStage(Collection<Image> logos, StylesConfig styles, @Named("newsDisplayPolicy") PreferenceComboBox<KeyStringValueItem<String>> newsDisplayPolicy) { BorderPane containerPane = new BorderPane(); browser.setId("newsBrowser"); containerPane.getStyleClass().addAll(Style.CONTAINER.css()); containerPane.getStyleClass().add("-pdfsam-news-pane"); containerPane.setCenter(browser);/* w w w . ja va2s .c o m*/ HBox bottom = new HBox(); ClosePane closePane = new ClosePane(); HBox.setHgrow(closePane, Priority.ALWAYS); HBox comboPanel = new HBox(new Label(DefaultI18nContext.getInstance().i18n("Show this:")), newsDisplayPolicy); comboPanel.getStyleClass().addAll(Style.CONTAINER.css()); comboPanel.getStyleClass().add("-pdfsam-news-pane-bottom"); bottom.getChildren().addAll(comboPanel, closePane); containerPane.setBottom(bottom); Scene scene = new Scene(containerPane); scene.getStylesheets().addAll(styles.styles()); scene.setOnKeyReleased(new HideOnEscapeHandler(this)); setScene(scene); setTitle(DefaultI18nContext.getInstance().i18n("What's new")); getIcons().addAll(logos); setMaximized(false); }
From source file:Main.java
@Override public void start(Stage primaryStage) { final Label markerText = new Label(); StackPane.setAlignment(markerText, Pos.TOP_CENTER); String workingDir = System.getProperty("user.dir"); final File f = new File(workingDir, "../media/omgrobots.flv"); final Media m = new Media(f.toURI().toString()); final ObservableMap<String, Duration> markers = m.getMarkers(); markers.put("Robot Finds Wall", Duration.millis(3100)); markers.put("Then Finds the Green Line", Duration.millis(5600)); markers.put("Robot Grabs Sled", Duration.millis(8000)); markers.put("And Heads for Home", Duration.millis(11500)); final MediaPlayer mp = new MediaPlayer(m); mp.setOnMarker(new EventHandler<MediaMarkerEvent>() { @Override//from w ww . j av a 2s. com public void handle(final MediaMarkerEvent event) { Platform.runLater(new Runnable() { @Override public void run() { markerText.setText(event.getMarker().getKey()); } }); } }); final MediaView mv = new MediaView(mp); final StackPane root = new StackPane(); root.getChildren().addAll(mv, markerText); root.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { mp.seek(Duration.ZERO); markerText.setText(""); } }); final Scene scene = new Scene(root, 960, 540); final URL stylesheet = getClass().getResource("media.css"); scene.getStylesheets().add(stylesheet.toString()); primaryStage.setScene(scene); primaryStage.setTitle("Video Player 2"); primaryStage.show(); mp.play(); }
From source file:org.kordamp.javatrove.example04.view.AppView.java
public Scene createScene() { String basename = getClass().getPackage().getName().replace('.', '/') + "/app"; URL fxml = getClass().getClassLoader().getResource(basename + ".fxml"); FXMLLoader fxmlLoader = new FXMLLoader(fxml); fxmlLoader.setControllerFactory(param -> AppView.this); Parent root = null;//from w w w . ja v a 2s.c o m try { root = (Parent) fxmlLoader.load(); } catch (IOException e) { throw new IllegalStateException(e); } organization.textProperty().addListener((observable, oldValue, newValue) -> { model.setState(isBlank(newValue) ? DISABLED : READY); }); model.stateProperty().addListener((observable, oldValue, newValue) -> Platform.runLater(() -> { switch (newValue) { case DISABLED: enabled.setValue(false); running.setValue(false); break; case READY: enabled.setValue(true); running.setValue(false); break; case RUNNING: enabled.setValue(false); running.setValue(true); break; } })); ObservableList<Repository> items = createJavaFXThreadProxyList(model.getRepositories().sorted()); repositories.setItems(items); EventStreams.sizeOf(items).subscribe(v -> total.setText(String.valueOf(v))); organization.textProperty().bindBidirectional(model.organizationProperty()); bindBidirectional(limit.textProperty(), model.limitProperty(), new NumberStringConverter()); loadButton.disableProperty().bind(Bindings.not(enabled)); cancelButton.disableProperty().bind(Bindings.not(running)); progress.visibleProperty().bind(running); Scene scene = new Scene(root); scene.getStylesheets().addAll(basename + ".css", "bootstrapfx.css"); return scene; }
From source file:projavafx.videoplayer3.VideoPlayer3.java
@Override public void start(Stage primaryStage) { final Label message = new Label("I \u2764 Robots"); message.setVisible(false);/*ww w . ja v a2s . co m*/ String workingDir = System.getProperty("user.dir"); final File f = new File(workingDir, "../media/omgrobots.flv"); final Media m = new Media(f.toURI().toString()); m.getMarkers().put("Split", Duration.millis(3000)); m.getMarkers().put("Join", Duration.millis(9000)); final MediaPlayer mp = new MediaPlayer(m); final MediaView mv1 = new MediaView(mp); mv1.setViewport(new Rectangle2D(0, 0, 960 / 2, 540)); StackPane.setAlignment(mv1, Pos.CENTER_LEFT); final MediaView mv2 = new MediaView(mp); mv2.setViewport(new Rectangle2D(960 / 2, 0, 960 / 2, 540)); StackPane.setAlignment(mv2, Pos.CENTER_RIGHT); StackPane root = new StackPane(); root.getChildren().addAll(message, mv1, mv2); root.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { mp.seek(Duration.ZERO); message.setVisible(false); } }); final Scene scene = new Scene(root, 960, 540); final URL stylesheet = getClass().getResource("media.css"); scene.getStylesheets().add(stylesheet.toString()); primaryStage.setScene(scene); primaryStage.setTitle("Video Player 3"); primaryStage.show(); mp.setOnMarker(new EventHandler<MediaMarkerEvent>() { @Override public void handle(final MediaMarkerEvent event) { Platform.runLater(new Runnable() { @Override public void run() { if (event.getMarker().getKey().equals("Split")) { message.setVisible(true); buildSplitTransition(mv1, mv2).play(); } else { buildJoinTransition(mv1, mv2).play(); } } }); } }); mp.play(); }
From source file:net.rptools.gui.GuiBuilder.java
/** Final GUI show. */ @ThreadPolicy(ThreadPolicy.ThreadId.MAIN) public void showGUI() { Platform.runLater(new Runnable() { @Override//ww w.j a va2 s . com public void run() { rootStage.setTitle("Maptool"); final Scene rootScene = new Scene(rootRegion); rootScene.getStylesheets().add(StylesheetMonitor.STYLESHEET); rootStage.setScene(rootScene); component.setRootScene(rootScene); rootStage.show(); component.stopSplasher(); } }); }
From source file:account.management.controller.loginController.java
@FXML private void onLoginButtonClick(ActionEvent event) { try {//from ww w .j a v a 2s. c o m String username = this.username.getText(); String password = this.password.getText(); User.username = username; this.login_btn.setDisable(true); this.login_btn.setText("Loading..."); Thread t = new Thread(() -> { try { HttpResponse<JsonNode> res = Unirest.get(MetaData.baseUrl + "login") .queryString("username", username).queryString("password", password).asJson(); JSONArray array = res.getBody().getArray(); JSONObject obj = array.getJSONObject(0); if (obj.getInt("inventory") == 1) User.inventory = true; if (obj.getInt("project") == 1) User.project = true; if (obj.getInt("lc") == 1) User.lc = true; if (obj.getInt("cnf") == 1) User.cnf = true; if (obj.getInt("deposit_voucher") == 1) User.deposit_voucher = true; if (obj.getInt("expense_voucher") == 1) User.expense_voucher = true; if (obj.getInt("sell") == 1) User.sell = true; if (obj.getInt("purchase") == 1) User.purchase = true; if (obj.getInt("party_create") == 1) User.party_create = true; if (obj.getInt("ledger_create") == 1) User.ledger = true; if (obj.getInt("voucher") == 1) User.voucher = true; if (obj.getInt("bank") == 1) User.bank = true; if (obj.getInt("inventory_report") == 1) User.inventory_report = true; if (obj.getInt("trial_balance") == 1) User.trial_balance = true; if (obj.getInt("balance_sheet") == 1) User.balance_sheet = true; if (obj.getInt("financial_statement") == 1) User.financial_statement = true; if (obj.getInt("database_maintanance") == 1) User.database_maintanance = true; Platform.runLater(() -> { try { this.login_btn.getScene().getWindow().hide(); Parent root; root = FXMLLoader.load(getClass().getResource(MetaData.viewPath + "home1.fxml")); Scene scene = new Scene(root); scene.getStylesheets().add("/style.css"); Stage stage = new Stage(); scene.setRoot(root); stage.setResizable(true); stage.setTitle("Home"); stage.setScene(scene); stage.showAndWait(); } catch (IOException ex) { Logger.getLogger(loginController.class.getName()).log(Level.SEVERE, null, ex); } }); } catch (Exception ex) { Platform.runLater(() -> { Msg.showError("Username or password is incorrect"); }); } finally { login_btn.setDisable(false); Platform.runLater(() -> { login_btn.setText("Login"); }); } }); t.start(); } catch (Exception e) { Msg.showError("Sorry. There is an error. Please try again"); } }
From source file:io.bitsquare.app.gui.BitsquareApp.java
@Override public void start(Stage primaryStage) throws IOException { bitsquareAppModule = new BitsquareAppModule(env, primaryStage); injector = Guice.createInjector(bitsquareAppModule); injector.getInstance(GuiceControllerFactory.class).setInjector(injector); // route uncaught exceptions to a user-facing dialog Thread.currentThread().setUncaughtExceptionHandler( (thread, throwable) -> Popups.handleUncaughtExceptions(Throwables.getRootCause(throwable))); // initialize the application data directory (if necessary) initAppDir(env.getRequiredProperty(APP_DATA_DIR_KEY)); // load and apply any stored settings User user = injector.getInstance(User.class); AccountSettings accountSettings = injector.getInstance(AccountSettings.class); Persistence persistence = injector.getInstance(Persistence.class); persistence.init();//from ww w . j a va 2s . c om User persistedUser = (User) persistence.read(user); user.applyPersistedUser(persistedUser); accountSettings.applyPersistedAccountSettings( (AccountSettings) persistence.read(accountSettings.getClass().getName())); // load the main view and create the main scene ViewLoader viewLoader = injector.getInstance(ViewLoader.class); ViewLoader.Item loaded = viewLoader.load(Navigation.Item.MAIN.getFxmlUrl(), false); Scene scene = new Scene((Parent) loaded.view, 1000, 600); scene.getStylesheets().setAll("/io/bitsquare/gui/bitsquare.css", "/io/bitsquare/gui/images.css"); // configure the system tray SystemTray systemTray = new SystemTray(primaryStage, this::stop); primaryStage.setOnCloseRequest(e -> stop()); scene.setOnKeyReleased(keyEvent -> { // For now we exit when closing/quit the app. // Later we will only hide the window (systemTray.hideStage()) and use the exit item in the system tray for // shut down. if (new KeyCodeCombination(KeyCode.W, KeyCombination.SHORTCUT_DOWN).match(keyEvent) || new KeyCodeCombination(KeyCode.Q, KeyCombination.SHORTCUT_DOWN).match(keyEvent)) stop(); }); // configure the primary stage primaryStage.setTitle(env.getRequiredProperty(APP_NAME_KEY)); primaryStage.setScene(scene); primaryStage.setMinWidth(75); primaryStage.setMinHeight(50); // on windows the title icon is also used as task bar icon in a larger size // on Linux no title icon is supported but also a large task bar icon is derived form that title icon String iconPath; if (Utilities.isOSX()) iconPath = ImageUtil.isRetina() ? "/images/window_icon@2x.png" : "/images/window_icon.png"; else if (Utilities.isWindows()) iconPath = "/images/task_bar_icon_windows.png"; else iconPath = "/images/task_bar_icon_linux.png"; if (iconPath != null) primaryStage.getIcons().add(new Image(getClass().getResourceAsStream(iconPath))); // make the UI visible primaryStage.show(); }
From source file:application.Main.java
@Override public void start(Stage primaryStage) throws InterruptedException { System.out.println(applicationTitle + " initialized!"); // define working variables String text = ""; Boolean terminateExecution = Boolean.FALSE; // does the specified FXML XML file path exist? String fxmlXmlFileFullPath = fxmlPath.equals("") ? fxmlXmlFileName : fxmlPath + "/" + fxmlXmlFileName; URL urlXml = Main.class.getResource(fxmlXmlFileFullPath); if (urlXml == null) { terminateExecution = Boolean.TRUE; text = Main.class.getName() + ": FXML XML File '" + fxmlXmlFileFullPath + "' not found in resource path!"; GenericUtilities.outputToSystemErr(text, systemErrorsDesired); }//from w w w. ja v a 2 s .c o m // does the specified FXML CSS file path exist? String fxmlCssFileFullPath = fxmlPath.equals("") ? fxmlCssFileName : fxmlPath + "/" + fxmlCssFileName; URL urlCss = Main.class.getResource(fxmlCssFileFullPath); if (urlCss == null) { terminateExecution = Boolean.TRUE; text = Main.class.getName() + ": FXML CSS File '" + fxmlCssFileFullPath + "' not found in resource path!"; GenericUtilities.outputToSystemErr(text, systemErrorsDesired); } if (terminateExecution) { text = Main.class.getName() + ": Execution terminated due to errors!"; GenericUtilities.outputToSystemErr(text, systemErrorsDesired); GenericUtilities.outputToSystemOut(text, systemOutputDesired); return; } // initialize and display the primary stage try { // load the FXML file and instantiate the "root" object FXMLLoader fxmlLoader = new FXMLLoader(urlXml); Parent root = (Parent) fxmlLoader.load(); controller = (FracKhemGUIController) fxmlLoader.getController(); controller.setStage(primaryStage); controller.setInitStageTitle(applicationTitle); // initialize and display the stage createTrayIcon(primaryStage); firstTime = Boolean.TRUE; Platform.setImplicitExit(Boolean.FALSE); Scene scene = new Scene(root); scene.getStylesheets().add(urlCss.toExternalForm()); primaryStage.setScene(scene); primaryStage.setTitle(applicationTitle + " - " + controller.getPropFileCurrFileVal()); primaryStage.show(); } catch (Exception e) { text = ExceptionUtils.getStackTrace(e); GenericUtilities.outputToSystemErr(text, systemErrorsDesired); text = Main.class.getName() + ": Execution terminated due to errors!"; GenericUtilities.outputToSystemErr(text, systemErrorsDesired); GenericUtilities.outputToSystemOut(text, systemOutputDesired); } }