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 stage) { Scene scene = new Scene(new Group()); stage.setScene(scene);//from w ww. j a v a 2 s .c o m stage.show(); stage.setWidth(300); stage.setHeight(200); final String[] greetings = new String[] { "Hello", "Hola", "1", "2" }; final ChoiceBox cb = new ChoiceBox(FXCollections.observableArrayList("1", "2", "3", "4")); cb.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() { public void changed(ObservableValue ov, Number value, Number new_value) { System.out.println(new_value.intValue()); } }); cb.setValue("2"); HBox hb = new HBox(); hb.getChildren().addAll(cb); 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(""); stage.setWidth(230);/*www . j a v a2 s . c o m*/ stage.setHeight(120); Path path = new Path(); path.getElements().add(new MoveTo(0.0f, 50.0f)); path.getElements().add(new LineTo(100.0f, 100.0f)); VBox vbox = new VBox(); vbox.getChildren().addAll(path); vbox.setSpacing(5); HBox root = new HBox(); root.getChildren().add(vbox); 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 primaryStage) { primaryStage.setTitle("HBox Test"); // HBox// w w w . j av a 2 s .com HBox hb = new HBox(); hb.setPadding(new Insets(15, 12, 15, 12)); hb.setSpacing(10); // Buttons Button btn1 = new Button(); btn1.setText("Button1"); hb.getChildren().add(btn1); Button btn2 = new Button(); btn2.setText("Button2"); hb.getChildren().add(btn2); Button btn3 = new Button(); btn3.setText("Button3"); hb.getChildren().add(btn3); Button btn4 = new Button(); btn4.setText("Button4"); hb.getChildren().add(btn4); // Adding HBox to the scene Scene scene = new Scene(hb); primaryStage.setScene(scene); primaryStage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { Group root = new Group(); Scene scene = new Scene(root, 260, 80); stage.setScene(scene);/*from w w w . j a v a2 s . co m*/ stage.setTitle("Password Field Sample"); VBox vb = new VBox(); vb.setPadding(new Insets(10, 0, 0, 10)); vb.setSpacing(10); HBox hb = new HBox(); hb.setSpacing(10); hb.setAlignment(Pos.CENTER_LEFT); Label label = new Label("Password"); final PasswordField pb = new PasswordField(); pb.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { if (!pb.getText().equals("abc")) { message.setText("Your password is incorrect!"); message.setTextFill(Color.web("red")); } else { message.setText("Your password has been confirmed"); message.setTextFill(Color.web("black")); } pb.setText(""); } }); hb.getChildren().addAll(label, pb); vb.getChildren().addAll(hb, message); scene.setRoot(vb); 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 a 2 s . co m stage.setHeight(180); HBox hbox = new HBox(); Label label1 = new Label("Search"); label1.setRotate(270); 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);/* w w w . j a v a2 s. c o m*/ stage.setHeight(180); HBox hbox = new HBox(); Label label1 = new Label("Search"); label1.setTranslateY(50); 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.setWidth(400);/* www . j a va 2s .co m*/ stage.setHeight(180); HBox hbox = new HBox(); Label label1 = new Label("Search"); label1.setFont(new Font("Arial", 30)); 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()); scene.setFill(Color.ALICEBLUE); stage.setScene(scene);//ww w. j av a 2 s.co m stage.show(); stage.setWidth(300); stage.setHeight(200); label.setStyle("-fx-font: 25 arial;"); label.setLayoutX(40); rect.setStroke(Color.BLUE); rect.setStrokeWidth(3); rect.setFill(Color.WHITE); final String[] greetings = new String[] { "A", "B", "C", "D", "E" }; final ChoiceBox<String> cb = new ChoiceBox<String>( FXCollections.observableArrayList("a", "b", "c", "d", "e")); 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);//w w w.j a v a2 s . c o m stage.setHeight(180); HBox hbox = new HBox(); Label label1 = new Label("Search"); label1.setFont(new Font("Arial", 30)); 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);/*from ww w. ja va 2 s.co m*/ stage.setHeight(180); HBox hbox = new HBox(); Label label1 = new Label("Search"); label1.setTextFill(Color.web("#0076a3")); hbox.setSpacing(10); hbox.getChildren().add((label1)); ((Group) scene.getRoot()).getChildren().add(hbox); stage.setScene(scene); stage.show(); }