List of usage examples for javafx.scene.layout FlowPane setAlignment
public final void setAlignment(Pos value)
From source file:Main.java
@Override public void start(Stage primaryStage) { final Label label = new Label("Progress:"); final ProgressBar progressBar = new ProgressBar(0); final ProgressIndicator progressIndicator = new ProgressIndicator(0); final Button startButton = new Button("Start"); final Button cancelButton = new Button("Cancel"); final TextArea textArea = new TextArea(); startButton.setOnAction((ActionEvent event) -> { startButton.setDisable(true);// w w w . j a va 2 s . co m progressBar.setProgress(0); progressIndicator.setProgress(0); textArea.setText(""); cancelButton.setDisable(false); copyWorker = createWorker(numFiles); progressBar.progressProperty().unbind(); progressBar.progressProperty().bind(copyWorker.progressProperty()); progressIndicator.progressProperty().unbind(); progressIndicator.progressProperty().bind(copyWorker.progressProperty()); copyWorker.messageProperty().addListener( (ObservableValue<? extends String> observable, String oldValue, String newValue) -> { textArea.appendText(newValue + "\n"); }); new Thread(copyWorker).start(); }); cancelButton.setOnAction((ActionEvent event) -> { startButton.setDisable(false); cancelButton.setDisable(true); copyWorker.cancel(true); progressBar.progressProperty().unbind(); progressBar.setProgress(0); progressIndicator.progressProperty().unbind(); progressIndicator.setProgress(0); textArea.appendText("File transfer was cancelled."); }); BorderPane root = new BorderPane(); Scene scene = new Scene(root, 500, 250, javafx.scene.paint.Color.WHITE); FlowPane topPane = new FlowPane(5, 5); topPane.setPadding(new Insets(5)); topPane.setAlignment(Pos.CENTER); topPane.getChildren().addAll(label, progressBar, progressIndicator); GridPane middlePane = new GridPane(); middlePane.setPadding(new Insets(5)); middlePane.setHgap(20); middlePane.setVgap(20); ColumnConstraints column1 = new ColumnConstraints(300, 400, Double.MAX_VALUE); middlePane.getColumnConstraints().addAll(column1); middlePane.setAlignment(Pos.CENTER); middlePane.add(textArea, 0, 0); FlowPane bottomPane = new FlowPane(5, 5); bottomPane.setPadding(new Insets(5)); bottomPane.setAlignment(Pos.CENTER); bottomPane.getChildren().addAll(startButton, cancelButton); root.setTop(topPane); root.setCenter(middlePane); root.setBottom(bottomPane); primaryStage.setScene(scene); primaryStage.show(); }
From source file:com.bekwam.mavenpomupdater.Main.java
@Override public void start(Stage primaryStage) throws Exception { ///*from w w w . j a va 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:com.thomaskuenneth.tkmactuning.TKMacTuning.java
@Override public void start(Stage primaryStage) { TabPane tabPane = new TabPane(); tabPane.setTabClosingPolicy(TabPane.TabClosingPolicy.UNAVAILABLE); // Found here: http://stackoverflow.com/a/17488304/5956451 tabPane.getStyleClass().add("floating"); // TODO: propper error handling JSONTokener t = new JSONTokener(getClass().getResourceAsStream("resources/plugins.json")); JSONArray a = new JSONArray(t); a.forEach((Object anObject) -> { JSONObject jsonObject = (JSONObject) anObject; addPlugin(tabPane, jsonObject.getString("class"), jsonObject.getString("pluginName")); });// w w w . j a va2 s . c o m FlowPane buttonsPane = new FlowPane(Orientation.HORIZONTAL); buttonsPane.setPadding(LayoutConstants.PADDING_1); buttonsPane.setHgap(LayoutConstants.HORIZONTAL_CONTROL_GAP); buttonsPane.setAlignment(Pos.BASELINE_LEFT); final Button buttonReread = new Button(getString("reread")); buttonReread.setOnAction(event -> { PluginManager.reread(this); }); buttonsPane.getChildren().add(buttonReread); final Button buttonApply = new Button(getString("apply")); buttonApply.setOnAction(event -> { PluginManager.save(this); }); buttonsPane.getChildren().add(buttonApply); statusbar = new StatusBar(); BorderPane borderPane = new BorderPane(tabPane); borderPane.setTop(buttonsPane); borderPane.setBottom(statusbar); primaryStage.setScene(new Scene(borderPane, 800, 600)); primaryStage.setTitle(getString("application_name")); ready(); primaryStage.show(); }