List of usage examples for javafx.scene.layout HBox setSpacing
public final void setSpacing(double value)
From source file:Main.java
@Override public void start(Stage primaryStage) { Group root = new Group(); Scene scene = new Scene(root, 330, 120, Color.WHITE); BorderPane mainPane = new BorderPane(); root.getChildren().add(mainPane);//from w w w. j av a2s. c o m final Label label = new Label("Files Transfer:"); final ProgressBar progressBar = new ProgressBar(0); final HBox hb = new HBox(); hb.setSpacing(5); hb.setAlignment(Pos.CENTER); hb.getChildren().addAll(label, progressBar); mainPane.setTop(hb); final Button startButton = new Button("Start"); final Button cancelButton = new Button("Cancel"); final HBox hb2 = new HBox(); hb2.setSpacing(5); hb2.setAlignment(Pos.CENTER); hb2.getChildren().addAll(startButton, cancelButton); mainPane.setBottom(hb2); startButton.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent event) { startButton.setDisable(true); progressBar.setProgress(0); cancelButton.setDisable(false); copyWorker = createWorker(); progressBar.progressProperty().unbind(); progressBar.progressProperty().bind(copyWorker.progressProperty()); copyWorker.messageProperty().addListener(new ChangeListener<String>() { public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) { System.out.println(newValue); } }); new Thread(copyWorker).start(); } }); cancelButton.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent event) { startButton.setDisable(false); cancelButton.setDisable(true); copyWorker.cancel(true); progressBar.progressProperty().unbind(); progressBar.setProgress(0); System.out.println("cancelled."); } }); primaryStage.setScene(scene); primaryStage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { Circle circle = new Circle(40); circle.setFill(Color.RED);/* w w w. ja v a2s.c om*/ circle.setStroke(Color.BLACK); circle.setStrokeWidth(2.0); Rectangle rect = new Rectangle(120, 75); rect.setFill(Color.RED); // Create a line Line line = new Line(0, 0, 150, 50); line.setStrokeWidth(5.0); line.setStroke(Color.GREEN); // Create a parallelogram Polygon parallelogram = new Polygon(); parallelogram.getPoints().addAll(30.0, 0.0, 130.0, 0.0, 120.00, 50.0, 0.0, 50.0); parallelogram.setFill(Color.AZURE); parallelogram.setStroke(Color.BLACK); // Create a hexagon Polyline hexagon = new Polyline(100.0, 0.0, 120.0, 20.0, 110.0, 140.0, 100.0, 60.0, 80.0, 40.0, 80.0, 120.0, 100.0, 0.0); hexagon.setFill(Color.WHITE); hexagon.setStroke(Color.BLACK); // A CHORD arc with no fill and a stroke Arc arc = new Arc(0, 0, 50, 100, 0, 90); arc.setFill(Color.TRANSPARENT); arc.setStroke(Color.BLACK); arc.setType(ArcType.CHORD); // Add all shapes to an HBox HBox root = new HBox(circle, rect, line, parallelogram, hexagon, arc); root.setSpacing(10); root.setStyle("-fx-padding: 10;" + "-fx-border-style: solid inside;" + "-fx-border-width: 2;" + "-fx-border-insets: 5;" + "-fx-border-radius: 5;" + "-fx-border-color: blue;"); Scene scene = new Scene(root); stage.setScene(scene); stage.setTitle("2D Shapes"); stage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { Scene scene = new Scene(new Group()); stage.setTitle("Label Sample"); stage.setWidth(400);/*from w w w . j a v a2 s .c om*/ stage.setHeight(180); HBox hbox = new HBox(); Label label1 = new Label("Search"); label1.setTextAlignment(TextAlignment.JUSTIFY); hbox.setSpacing(10); hbox.getChildren().add((label1)); ((Group) scene.getRoot()).getChildren().add(hbox); stage.setScene(scene); stage.show(); }
From source file:Main.java
@Override public void start(Stage primaryStage) { Group root = new Group(); Scene scene = new Scene(root, 330, 120, Color.WHITE); BorderPane mainPane = new BorderPane(); root.getChildren().add(mainPane);// w w w . j av a 2 s. co m final Label label = new Label("Files Transfer:"); final ProgressBar progressBar = new ProgressBar(0); final HBox hb = new HBox(); hb.setSpacing(5); hb.setAlignment(Pos.CENTER); hb.getChildren().addAll(label, progressBar); mainPane.setTop(hb); final Button startButton = new Button("Start"); final Button cancelButton = new Button("Cancel"); final HBox hb2 = new HBox(); hb2.setSpacing(5); hb2.setAlignment(Pos.CENTER); hb2.getChildren().addAll(startButton, cancelButton); mainPane.setBottom(hb2); startButton.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent event) { startButton.setDisable(true); progressBar.setProgress(0); cancelButton.setDisable(false); copyWorker = createWorker(); progressBar.progressProperty().unbind(); progressBar.progressProperty().bind(copyWorker.progressProperty()); copyWorker.messageProperty().addListener(new ChangeListener<String>() { public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) { System.out.println(newValue); } }); new Thread(copyWorker).start(); } }); cancelButton.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent event) { startButton.setDisable(false); cancelButton.setDisable(true); copyWorker.cancel(true); progressBar.progressProperty().unbind(); progressBar.setProgress(0); System.out.println("cancelled."); } }); primaryStage.setScene(scene); primaryStage.show(); }
From source file:Main.java
@Override public void start(Stage primaryStage) { primaryStage.setTitle("Background Processes"); Group root = new Group(); Scene scene = new Scene(root, 330, 120, Color.WHITE); BorderPane mainPane = new BorderPane(); root.getChildren().add(mainPane);// ww w . jav a 2s . co m final Label label = new Label("Files Transfer:"); final ProgressIndicator progressIndicator = new ProgressIndicator(0); final HBox hb = new HBox(); hb.setSpacing(5); hb.setAlignment(Pos.CENTER); hb.getChildren().addAll(label, progressIndicator); mainPane.setTop(hb); final Button startButton = new Button("Start"); final Button cancelButton = new Button("Cancel"); final HBox hb2 = new HBox(); hb2.setSpacing(5); hb2.setAlignment(Pos.CENTER); hb2.getChildren().addAll(startButton, cancelButton); mainPane.setBottom(hb2); startButton.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent event) { startButton.setDisable(true); progressIndicator.setProgress(0); cancelButton.setDisable(false); copyWorker = createWorker(); progressIndicator.progressProperty().unbind(); progressIndicator.progressProperty().bind(copyWorker.progressProperty()); copyWorker.messageProperty().addListener(new ChangeListener<String>() { public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) { System.out.println(newValue); } }); new Thread(copyWorker).start(); } }); cancelButton.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent event) { startButton.setDisable(false); cancelButton.setDisable(true); copyWorker.cancel(true); progressIndicator.progressProperty().unbind(); progressIndicator.setProgress(0); System.out.println("cancelled."); } }); primaryStage.setScene(scene); primaryStage.show(); }
From source file:Main.java
@Override public void start(Stage primaryStage) { primaryStage.setTitle("Background Processes"); Group root = new Group(); Scene scene = new Scene(root, 330, 120, Color.WHITE); BorderPane mainPane = new BorderPane(); root.getChildren().add(mainPane);//from w w w . j a v a2 s.c o m final Label label = new Label("Files Transfer:"); final ProgressBar progressBar = new ProgressBar(0); final HBox hb = new HBox(); hb.setSpacing(5); hb.setAlignment(Pos.CENTER); hb.getChildren().addAll(label, progressBar); mainPane.setTop(hb); final Button startButton = new Button("Start"); final Button cancelButton = new Button("Cancel"); final HBox hb2 = new HBox(); hb2.setSpacing(5); hb2.setAlignment(Pos.CENTER); hb2.getChildren().addAll(startButton, cancelButton); mainPane.setBottom(hb2); startButton.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent event) { startButton.setDisable(true); progressBar.setProgress(0); cancelButton.setDisable(false); copyWorker = createWorker(); progressBar.progressProperty().unbind(); progressBar.progressProperty().bind(copyWorker.progressProperty()); copyWorker.messageProperty().addListener(new ChangeListener<String>() { public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) { System.out.println(newValue); } }); new Thread(copyWorker).start(); } }); cancelButton.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent event) { startButton.setDisable(false); cancelButton.setDisable(true); copyWorker.cancel(true); progressBar.progressProperty().unbind(); progressBar.setProgress(0); System.out.println("cancelled."); } }); primaryStage.setScene(scene); primaryStage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { Scene scene = new Scene(new Group()); stage.setTitle("Checkbox Sample"); stage.setWidth(230);/* www . j a v a 2 s . c o m*/ stage.setHeight(120); for (int i = 0; i < names.length; i++) { final CheckBox cb = cbs[i] = new CheckBox(names[i]); cb.selectedProperty().addListener(new ChangeListener<Boolean>() { public void changed(ObservableValue ov, Boolean old_val, Boolean new_val) { System.out.println(new_val); } }); } VBox vbox = new VBox(); vbox.getChildren().addAll(cbs); vbox.setSpacing(5); HBox hbox = new HBox(); hbox.setPadding(new Insets(0, 0, 0, 5)); StackPane stack = new StackPane(); stack.getChildren().add(hbox); HBox root = new HBox(); root.getChildren().add(vbox); root.getChildren().add(stack); root.setSpacing(40); root.setPadding(new Insets(20, 10, 10, 20)); ((Group) scene.getRoot()).getChildren().add(root); stage.setScene(scene); stage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { Scene scene = new Scene(new Group()); scene.setFill(Color.ALICEBLUE); stage.setScene(scene);//from w w w .j a v a2 s .com stage.show(); stage.setTitle("ChoiceBox Sample"); stage.setWidth(300); stage.setHeight(200); label.setStyle("-fx-font: 25 arial;"); label.setLayoutX(40); rect.setArcHeight(8); rect.setArcWidth(8); rect.setStroke(Color.BLUE); rect.setStrokeWidth(3); rect.setFill(Color.WHITE); final String[] greetings = new String[] { "Hello", "Hola", "??????", "?", "?????" }; final ChoiceBox cb = new ChoiceBox( FXCollections.observableArrayList("English", "Espaol", "???????", "????", "???")); cb.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() { public void changed(ObservableValue ov, Number value, Number new_value) { label.setText(greetings[new_value.intValue()]); } }); cb.setTooltip(new Tooltip("Select the language")); cb.setValue("English"); HBox hb = new HBox(); hb.getChildren().addAll(cb, label); hb.setSpacing(30); hb.setAlignment(Pos.CENTER); hb.setPadding(new Insets(10, 0, 0, 10)); ((Group) scene.getRoot()).getChildren().add(hb); }
From source file:Main.java
@Override public void start(Stage stage) { Scene scene = new Scene(new Group()); stage.setTitle("Label Sample"); stage.setWidth(400);/*from www. ja va 2s . com*/ stage.setHeight(180); HBox hbox = new HBox(); Image image = new Image(getClass().getResourceAsStream("labels.jpg")); Label label1 = new Label("Search", new ImageView(image)); hbox.setSpacing(10); hbox.getChildren().add((label1)); ((Group) scene.getRoot()).getChildren().add(hbox); stage.setScene(scene); stage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { Scene scene = new Scene(new Group()); stage.setTitle("Label Sample"); stage.setWidth(400);//ww w. j a va 2 s .c om stage.setHeight(180); HBox hbox = new HBox(); Image image = new Image(getClass().getResourceAsStream("labels.jpg")); Label label1 = new Label("Search", new ImageView(image)); hbox.setSpacing(10); hbox.getChildren().add((label1)); ((Group) scene.getRoot()).getChildren().add(hbox); label1.setLabelFor(hbox); System.out.println(label1.labelForProperty()); stage.setScene(scene); stage.show(); }