â—Ž Sample code
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;
public class Sample extends Application {
public static void main(String[] args) {
launch(args);
}
public void start(Stage stage) {
stage.setWidth(500);
stage.setHeight(500);
Button button1 = new Button("1");
Button button2 = new Button("2");
Button button3 = new Button("3");
Button button4 = new Button("4");
button1.setPrefSize(100,100);
button2.setPrefSize(100,100);
button3.setPrefSize(100,100);
button4.setPrefSize(100,100);
HBox box = new HBox(1);//For VBox, here is VBox box= new VBox(1)Change to
   box.getChildren().addAll(button1,button2,button3,button4);
BorderPane root = new BorderPane();
root.setLeft(box);
stage.setScene(new Scene(root));
stage.show();
}
}
Recommended Posts