List of usage examples for javafx.scene.layout StackPane getChildren
@Override
public ObservableList<Node> getChildren()
From source file:com.cdd.bao.editor.endpoint.BrowseEndpoint.java
public BrowseEndpoint(Stage stage) { this.stage = stage; stage.setTitle("BioAssay Schema Browser"); treeRoot = new TreeItem<>(new Branch(this)); treeView = new TreeView<>(treeRoot); treeView.setEditable(true);/*w ww . j a v a2 s . c o m*/ treeView.setCellFactory(p -> new BrowseTreeCell()); treeView.getSelectionModel().selectedItemProperty().addListener((observable, oldval, newval) -> { changeValue(newval.getValue()); }); display = new DisplaySchema(); StackPane sp1 = new StackPane(), sp2 = new StackPane(); sp1.getChildren().add(treeView); sp2.getChildren().add(display); splitter = new SplitPane(); splitter.setOrientation(Orientation.HORIZONTAL); splitter.getItems().addAll(sp1, sp2); splitter.setDividerPositions(0.4, 1.0); root = new BorderPane(); root.setTop(menuBar); root.setCenter(splitter); Scene scene = new Scene(root, 700, 600, Color.WHITE); stage.setScene(scene); treeView.setShowRoot(false); rebuildTree(); Platform.runLater(() -> treeView.getFocusModel().focus(treeView.getSelectionModel().getSelectedIndex())); // for some reason it defaults to not the first item new Thread(() -> backgroundLoadTemplates()).start(); }
From source file:com.bekwam.mavenpomupdater.Main.java
@Override public void start(Stage primaryStage) throws Exception { ////from w w w .ja v a 2s .c om // 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:org.pdfsam.PdfsamApp.java
private void initScene() { 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); StylesConfig styles = ApplicationContextHolder.getContext().getBean(StylesConfig.class); mainScene = new Scene(main); mainScene.getStylesheets().addAll(styles.styles()); mainScene.getAccelerators().put(new KeyCodeCombination(KeyCode.L, KeyCombination.SHORTCUT_DOWN), () -> eventStudio().broadcast(new ShowStageRequest(), "LogStage")); }
From source file:org.jfree.fx.demo.FXGraphics2DDemo1.java
@Override public void start(Stage stage) throws Exception { XYDataset dataset = createDataset(); JFreeChart chart = createChart(dataset); ChartCanvas canvas = new ChartCanvas(chart); StackPane stackPane = new StackPane(); stackPane.getChildren().add(canvas); // Bind canvas size to stack pane size. canvas.widthProperty().bind(stackPane.widthProperty()); canvas.heightProperty().bind(stackPane.heightProperty()); stage.setScene(new Scene(stackPane)); stage.setTitle("FXGraphics2DDemo1.java"); stage.setWidth(700);/*from w w w . j av a 2s. co m*/ stage.setHeight(390); stage.show(); }
From source file:calendarioSeries.vistas.MainViewController.java
public void populateImagenes() { Platform.runLater(new Runnable() { @Override// www .j a v a2 s . c o m public void run() { imagenes.getChildren().clear(); for (Serie serie : series) { //System.out.println(serie.getLastVisto()); try { Image image = new Image(serie.getUrlImagen()); ImageView poster = new ImageView(); ContextMenu menu = new ContextMenu(); //String css = MainApp.class.getResource("resources/MainTheme.css").toExternalForm(); MenuItem delete = new MenuItem("Eliminar"); delete.setId(serie.getId()); delete.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { menu.hide(); MenuItem clicked = (MenuItem) event.getSource(); String toDelete = clicked.getId(); for (Serie serie : series) { if (serie.getId().equals(toDelete)) { series.remove(serie); populateImagenes(); showDetallesMes(mesActual); } } event.consume(); } }); menu.getItems().add(delete); poster.setId(serie.getTitulo()); poster.setImage(image); poster.setCache(true); // poster.setPreserveRatio(true); poster.setFitWidth(210); poster.setFitHeight(300); poster.setOnContextMenuRequested(new EventHandler<ContextMenuEvent>() { @Override public void handle(ContextMenuEvent event) { menu.show(poster, event.getScreenX(), event.getScreenY()); //menu.getScene().getRoot().getStylesheets().add(css); event.consume(); } }); poster.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { if (event.getButton() == MouseButton.PRIMARY) { try { //serieToPass = serie; sceneToPass = mainApp.scene; FXMLLoader loader = new FXMLLoader( getClass().getResource("DetailsSerieController.fxml")); Parent root = loader.load(); DetailsSerieController controller = loader.getController(); controller.setData(serie, series); controller.setMainApp(mainApp); Scene scene = new Scene(root); mainApp.primaryStage.setScene(scene); mainApp.primaryStage.show(); } catch (IOException ex) { ex.printStackTrace(); } } } }); imagenes.getChildren().add(poster); } catch (IllegalArgumentException e) { Image image = new Image("file:src/calendarioSeries/resources/no-image.png"); ImageView poster = new ImageView(); ContextMenu menu = new ContextMenu(); MenuItem delete = new MenuItem("Eliminar"); delete.setId(serie.getId()); delete.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { menu.hide(); MenuItem clicked = (MenuItem) event.getSource(); String toDelete = clicked.getId(); for (Serie serie : series) { if (serie.getId().equals(toDelete)) { series.remove(serie); populateImagenes(); showDetallesMes(mesActual); } } event.consume(); } }); menu.getItems().add(delete); poster.setId(serie.getTitulo()); poster.setImage(image); poster.setCache(true); //poster.setPreserveRatio(true); poster.setFitWidth(210); poster.setFitHeight(300); poster.setOnContextMenuRequested(new EventHandler<ContextMenuEvent>() { @Override public void handle(ContextMenuEvent event) { menu.show(poster, event.getScreenX(), event.getScreenY()); event.consume(); } }); Text text = new Text(serie.getTitulo()); text.getStyleClass().add("label"); StackPane pane = new StackPane(); pane.getChildren().addAll(poster, text); imagenes.getChildren().add(pane); } finally { rellenarArchivo(); } } } }); }
From source file:gov.va.isaac.gui.ConceptNode.java
/** * descriptionReader is optional/* w ww .ja v a2 s .c om*/ */ public ConceptNode(ConceptVersionBI initialConcept, boolean flagAsInvalidWhenBlank, ObservableList<SimpleDisplayConcept> dropDownOptions, Function<ConceptVersionBI, String> descriptionReader) { c_ = initialConcept; //We can't simply use the ObservableList from the CommonlyUsedConcepts, because it infinite loops - there doesn't seem to be a way //to change the items in the drop down without changing the selection. So, we have this hack instead. listChangeListener_ = new ListChangeListener<SimpleDisplayConcept>() { @Override public void onChanged(Change<? extends SimpleDisplayConcept> c) { //TODO I still have an infinite loop here. Find and fix. logger.debug("updating concept dropdown"); disableChangeListener_ = true; SimpleDisplayConcept temp = cb_.getValue(); cb_.setItems(FXCollections.observableArrayList(dropDownOptions_)); cb_.setValue(temp); cb_.getSelectionModel().select(temp); disableChangeListener_ = false; } }; descriptionReader_ = (descriptionReader == null ? (conceptVersion) -> { return conceptVersion == null ? "" : OTFUtility.getDescription(conceptVersion); } : descriptionReader); dropDownOptions_ = dropDownOptions == null ? AppContext.getService(CommonlyUsedConcepts.class).getObservableConcepts() : dropDownOptions; dropDownOptions_.addListener(new WeakListChangeListener<SimpleDisplayConcept>(listChangeListener_)); conceptBinding_ = new ObjectBinding<ConceptVersionBI>() { @Override protected ConceptVersionBI computeValue() { return c_; } }; flagAsInvalidWhenBlank_ = flagAsInvalidWhenBlank; cb_ = new ComboBox<>(); cb_.setConverter(new StringConverter<SimpleDisplayConcept>() { @Override public String toString(SimpleDisplayConcept object) { return object == null ? "" : object.getDescription(); } @Override public SimpleDisplayConcept fromString(String string) { return new SimpleDisplayConcept(string, 0); } }); cb_.setValue(new SimpleDisplayConcept("", 0)); cb_.setEditable(true); cb_.setMaxWidth(Double.MAX_VALUE); cb_.setPrefWidth(ComboBox.USE_COMPUTED_SIZE); cb_.setMinWidth(200.0); cb_.setPromptText("Type, drop or select a concept"); cb_.setItems(FXCollections.observableArrayList(dropDownOptions_)); cb_.setVisibleRowCount(11); cm_ = new ContextMenu(); MenuItem copyText = new MenuItem("Copy Description"); copyText.setGraphic(Images.COPY.createImageView()); copyText.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { CustomClipboard.set(cb_.getEditor().getText()); } }); cm_.getItems().add(copyText); CommonMenusNIdProvider nidProvider = new CommonMenusNIdProvider() { @Override public Set<Integer> getNIds() { Set<Integer> nids = new HashSet<>(); if (c_ != null) { nids.add(c_.getNid()); } return nids; } }; CommonMenuBuilderI menuBuilder = CommonMenus.CommonMenuBuilder.newInstance(); menuBuilder.setInvisibleWhenFalse(isValid); CommonMenus.addCommonMenus(cm_, menuBuilder, nidProvider); cb_.getEditor().setContextMenu(cm_); updateGUI(); new LookAheadConceptPopup(cb_); if (cb_.getValue().getNid() == 0) { if (flagAsInvalidWhenBlank_) { isValid.setInvalid("Concept Required"); } } else { isValid.setValid(); } cb_.valueProperty().addListener(new ChangeListener<SimpleDisplayConcept>() { @Override public void changed(ObservableValue<? extends SimpleDisplayConcept> observable, SimpleDisplayConcept oldValue, SimpleDisplayConcept newValue) { if (newValue == null) { logger.debug("Combo Value Changed - null entry"); } else { logger.debug("Combo Value Changed: {} {}", newValue.getDescription(), newValue.getNid()); } if (disableChangeListener_) { logger.debug("change listener disabled"); return; } if (newValue == null) { //This can happen if someone calls clearSelection() - it passes in a null. cb_.setValue(new SimpleDisplayConcept("", 0)); return; } else { if (newValue.shouldIgnoreChange()) { logger.debug("One time change ignore"); return; } //Whenever the focus leaves the combo box editor, a new combo box is generated. But, the new box will have 0 for an id. detect and ignore if (oldValue != null && oldValue.getDescription().equals(newValue.getDescription()) && newValue.getNid() == 0) { logger.debug("Not a real change, ignore"); newValue.setNid(oldValue.getNid()); return; } lookup(); } } }); AppContext.getService(DragRegistry.class).setupDragAndDrop(cb_, new SingleConceptIdProvider() { @Override public String getConceptId() { return cb_.getValue().getNid() + ""; } }, true); pi_ = new ProgressIndicator(ProgressIndicator.INDETERMINATE_PROGRESS); pi_.visibleProperty().bind(isLookupInProgress_); pi_.setPrefHeight(16.0); pi_.setPrefWidth(16.0); pi_.setMaxWidth(16.0); pi_.setMaxHeight(16.0); lookupFailImage_ = Images.EXCLAMATION.createImageView(); lookupFailImage_.visibleProperty().bind(isValid.not().and(isLookupInProgress_.not())); Tooltip t = new Tooltip(); t.textProperty().bind(isValid.getReasonWhyInvalid()); Tooltip.install(lookupFailImage_, t); StackPane sp = new StackPane(); sp.setMaxWidth(Double.MAX_VALUE); sp.getChildren().add(cb_); sp.getChildren().add(lookupFailImage_); sp.getChildren().add(pi_); StackPane.setAlignment(cb_, Pos.CENTER_LEFT); StackPane.setAlignment(lookupFailImage_, Pos.CENTER_RIGHT); StackPane.setMargin(lookupFailImage_, new Insets(0.0, 30.0, 0.0, 0.0)); StackPane.setAlignment(pi_, Pos.CENTER_RIGHT); StackPane.setMargin(pi_, new Insets(0.0, 30.0, 0.0, 0.0)); hbox_ = new HBox(); hbox_.setSpacing(5.0); hbox_.setAlignment(Pos.CENTER_LEFT); hbox_.getChildren().add(sp); HBox.setHgrow(sp, Priority.SOMETIMES); }
From source file:de.hs.mannheim.modUro.controller.diagram.fx.ChartViewerSkin.java
/** * Creates the node representing this control. * * @return The node.// w w w . ja v a 2 s .c o m */ private BorderPane createNode(ChartViewer control) { BorderPane borderPane = new BorderPane(); borderPane.setPrefSize(800, 500); StackPane sp = new StackPane(); sp.setMinSize(10, 10); sp.setPrefSize(150, 200); this.canvas = new ChartCanvas(getSkinnable().getChart()); this.canvas.setTooltipEnabled(control.isTooltipEnabled()); this.canvas.addChartMouseListener(control); this.canvas.widthProperty().bind(sp.widthProperty()); this.canvas.heightProperty().bind(sp.heightProperty()); this.canvas.addMouseHandler(new ZoomHandlerFX("zoom", control)); sp.getChildren().add(this.canvas); borderPane.setCenter(sp); return borderPane; }
From source file:com.jscriptive.moneyfx.ui.chart.ChartFrame.java
public void yearlyInOutToggled(ActionEvent actionEvent) { final NumberAxis xAxis = new NumberAxis(); final CategoryAxis yAxis = new CategoryAxis(); yAxis.setLabel("In/Out in Euro"); xAxis.setLabel("Year"); final BarChart<Number, String> barChart = new BarChart<>(xAxis, yAxis); barChart.setTitle("Yearly in/out"); chartFrame.setCenter(barChart);//w w w .j a v a 2 s. c om ToggleButton toggle = (ToggleButton) actionEvent.getTarget(); if (toggle.isSelected()) { Account account = accountCombo.getValue(); String accountLabel = getAccountLabel(account); XYChart.Series<Number, String> inSeries = new XYChart.Series<>(); inSeries.setName("In" + accountLabel); barChart.getData().add(inSeries); XYChart.Series<Number, String> outSeries = new XYChart.Series<>(); outSeries.setName("Out" + accountLabel); barChart.getData().add(outSeries); ValueRange<LocalDate> period = getTransactionOpRange(account, yearCombo.getValue()); if (period.isEmpty()) { return; } ObservableList<String> categories = FXCollections.observableArrayList(); for (int y = period.from().getYear(); y < period.to().getYear() + 6; y++) { categories.add(String.valueOf(y)); } yAxis.setCategories(categories); Service<Void> service = new Service<Void>() { @Override protected Task<Void> createTask() { return new Task<Void>() { @Override protected Void call() throws Exception { List<TransactionVolume> incomingVolumes = (account == ALL_ACCOUNTS) ? transactionRepository.getYearlyIncomingVolumes(false) : transactionRepository.getYearlyIncomingVolumesOfAccount(account, false); if (INTEGER_ZERO.compareTo(yearCombo.getValue()) < 0) { incomingVolumes = incomingVolumes.stream() .filter(v -> v.getYear().equals(yearCombo.getValue())) .sorted((v1, v2) -> v1.getDate().compareTo(v2.getDate())).collect(toList()); } for (TransactionVolume volume : incomingVolumes) { XYChart.Data<Number, String> inData = new XYChart.Data<>(volume.getVolume(), String.valueOf(volume.getYear())); Platform.runLater(() -> { inSeries.getData().add(inData); StackPane node = (StackPane) inData.getNode(); node.getChildren().add( new Label(CurrencyFormat.getInstance().format(volume.getVolume()))); node.addEventHandler(MOUSE_CLICKED, event -> handleYearlyInOutChartMouseClickEvent( (account == ALL_ACCOUNTS) ? null : account, ofYearDay(volume.getYear(), 1), event)); }); } List<TransactionVolume> outgoingVolumes = (account == ALL_ACCOUNTS) ? transactionRepository.getYearlyOutgoingVolumes(false) : transactionRepository.getYearlyOutgoingVolumesOfAccount(account, false); if (INTEGER_ZERO.compareTo(yearCombo.getValue()) < 0) { outgoingVolumes = outgoingVolumes.stream() .filter(v -> v.getYear().equals(yearCombo.getValue())) .sorted((v1, v2) -> v1.getDate().compareTo(v2.getDate())).collect(toList()); } for (TransactionVolume volume : outgoingVolumes) { XYChart.Data<Number, String> outData = new XYChart.Data<>(volume.getVolume().abs(), String.valueOf(volume.getYear())); Platform.runLater(() -> { outSeries.getData().add(outData); StackPane node = (StackPane) outData.getNode(); node.getChildren().add( new Label(CurrencyFormat.getInstance().format(volume.getVolume()))); node.addEventHandler(MOUSE_CLICKED, event -> handleYearlyInOutChartMouseClickEvent( (account == ALL_ACCOUNTS) ? null : account, ofYearDay(volume.getYear(), 1), event)); }); } return null; } }; } }; service.start(); } }
From source file:jp.ac.tohoku.ecei.sb.metabolome.lims.gui.MainWindowController.java
@FXML void onShowCompoundIntensity(MouseEvent event) { if (tableCompound.getSelectionModel().isEmpty()) return;/* w w w . ja va 2s .c o m*/ for (CompoundImpl compound : tableCompound.getSelectionModel().getSelectedItems()) { JFreeChart chart = getChartForCompound(compound); StackPane stackPane = new StackPane(); ChartCanvas chartCanvas = new ChartCanvas(chart); stackPane.getChildren().add(chartCanvas); chartCanvas.widthProperty().bind(stackPane.widthProperty()); chartCanvas.heightProperty().bind(stackPane.heightProperty()); Scene scene = new Scene(stackPane); Stage stage = new Stage(StageStyle.UTILITY); stage.setScene(scene); stage.setWidth(800); stage.setHeight(600); stage.setTitle(compound.toString()); stage.show(); } }
From source file:uk.co.everywheremusic.viewcontroller.SetupScene.java
private void startSetupWindow(Stage primaryStage) { try {//from w ww . ja v a 2 s. com installFolder = new File(".").getCanonicalPath() + Globals.INSTALL_EXT; } catch (IOException ex) { Logger.getLogger(SetupScene.class.getName()).log(Level.SEVERE, null, ex); installFolder = System.getProperty("user.dir") + Globals.INSTALL_EXT; } primaryStage.setTitle(Globals.APP_NAME); grid = new GridPane(); grid.setAlignment(Pos.CENTER); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(25, 25, 25, 25)); column1 = new ColumnConstraints(100, 100, Double.MAX_VALUE); column1.setHgrow(Priority.ALWAYS); column2 = new ColumnConstraints(100, 100, Double.MAX_VALUE); column2.setHgrow(Priority.ALWAYS); column3 = new ColumnConstraints(100, 100, Double.MAX_VALUE); column3.setHgrow(Priority.ALWAYS); column4 = new ColumnConstraints(100, 100, Double.MAX_VALUE); column4.setHgrow(Priority.ALWAYS); grid.getColumnConstraints().addAll(column1, column2, column3, column4); sceneTitle = new Label(Globals.SETUP_FRAME_TITLE); sceneTitle.setId(Globals.CSS_TITLE_ID); sceneTitle.setPrefWidth(Double.MAX_VALUE); sceneTitle.setAlignment(Pos.CENTER); ImageView imageView = null; try { imageView = new ImageView(); String img = new File(Globals.IC_LOGO).toURI().toURL().toString(); imgLogo = new Image(img); imageView.setImage(imgLogo); } catch (MalformedURLException ex) { Logger.getLogger(ServerScene.class.getName()).log(Level.SEVERE, null, ex); } GridPane titlePane = new GridPane(); ColumnConstraints c1 = new ColumnConstraints(50); ColumnConstraints c2 = new ColumnConstraints(400); titlePane.getColumnConstraints().addAll(c1, c2); titlePane.add(imageView, 0, 0); titlePane.add(sceneTitle, 1, 0); titlePane.setAlignment(Pos.CENTER); grid.add(titlePane, 0, 0, 4, 1); lblFolder = new Label(Globals.SETUP_LBL_MUSIC_FOLDER); grid.add(lblFolder, 0, 2, 3, 1); txtFolder = new TextField(); txtFolder.setText("/home/kyle/Music/Test music"); grid.add(txtFolder, 0, 3, 3, 1); btnFolder = new Button(Globals.SETUP_BTN_MUSIC_FOLDER); btnFolder.setPrefWidth(Double.MAX_VALUE); grid.add(btnFolder, 3, 3); final DirectoryChooser dirChooser = new DirectoryChooser(); btnFolder.setOnAction((ActionEvent event) -> { File dir = dirChooser.showDialog(primaryStage); if (dir != null) { txtFolder.setText(dir.getAbsolutePath()); } }); lblPassword = new Label("Choose a password:"); grid.add(lblPassword, 0, 4, 2, 1); lblConfirmPassword = new Label("Confirm your password:"); grid.add(lblConfirmPassword, 2, 4, 2, 1); txtPassword = new PasswordField(); grid.add(txtPassword, 0, 5, 2, 1); txtConfirmPassword = new PasswordField(); grid.add(txtConfirmPassword, 2, 5, 1, 1); textArea = new TextArea(); textArea.setPrefHeight(Double.MAX_VALUE); textArea.setDisable(true); textArea.setWrapText(true); grid.add(textArea, 0, 7, 4, 2); StackPane progressPane = new StackPane(); lblProgress = new Label(Globals.SETUP_LBL_PERCENT); lblProgress.setId(Globals.CSS_PROGBAR_LBL_ID); lblProgress.setVisible(false); progressBar = new ProgressBar(0); progressBar.setPrefWidth(Double.MAX_VALUE); progressBar.setVisible(false); progressPane.getChildren().addAll(progressBar, lblProgress); progressPane.setAlignment(Pos.CENTER_RIGHT); grid.add(progressPane, 0, 11, 3, 1); StackPane buttonPane = new StackPane(); btnInstall = new Button(Globals.SETUP_BTN_INSTALL); btnInstall.setPrefWidth(Double.MAX_VALUE); btnDone = new Button(Globals.SETUP_BTN_DONE); btnDone.setPrefWidth(Double.MAX_VALUE); btnDone.setVisible(false); buttonPane.getChildren().addAll(btnInstall, btnDone); grid.add(buttonPane, 3, 11); btnInstall.setOnAction((ActionEvent event) -> { boolean valid = validateForm(); if (valid) { lblFolder.setDisable(true); txtFolder.setDisable(true); btnFolder.setDisable(true); lblPassword.setDisable(true); txtPassword.setDisable(true); lblConfirmPassword.setDisable(true); txtConfirmPassword.setDisable(true); textArea.setDisable(false); lblProgress.setVisible(true); progressBar.setVisible(true); btnInstall.setDisable(true); musicFolder = txtFolder.getText(); password = txtPassword.getText(); setupWorker = createSetupWorker(); progressBar.progressProperty().unbind(); progressBar.progressProperty().bind(setupWorker.progressProperty()); setupWorker.messageProperty().addListener( (ObservableValue<? extends String> observable, String oldValue, String newValue) -> { String[] values = newValue.split("\\|"); lblProgress.setText(values[0] + "%"); textArea.appendText(values[1] + "\n"); if (values[1].equals(Globals.SETUP_MSG_DONE)) { btnInstall.setVisible(false); btnDone.setVisible(true); } }); new Thread(setupWorker).start(); } }); btnDone.setOnAction((ActionEvent event) -> { primaryStage.hide(); new ServerScene(installFolder, musicFolder).showWindow(new Stage()); }); try { String imgUrl = new File(Globals.IC_LOGO).toURI().toURL().toString(); javafx.scene.image.Image i = new javafx.scene.image.Image(imgUrl); primaryStage.getIcons().add(i); } catch (MalformedURLException ex) { Logger.getLogger(ServerScene.class.getName()).log(Level.SEVERE, null, ex); } scene = new Scene(grid, 600, 400); primaryStage.setScene(scene); scene.getStylesheets().add(SetupScene.class.getResource(Globals.CSS_FILE).toExternalForm()); // grid.setGridLinesVisible(true); primaryStage.show(); }