0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【個人的備忘録】 Eclipseのjavafxで作成する ボタンの配置(HBox・VBoxの場合)

Posted at
◎サンプルコード
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);//VBoxの場合は、ここを VBox box = new VBox(1)に変更する     
      box.getChildren().addAll(button1,button2,button3,button4);


		BorderPane root = new BorderPane();
		root.setLeft(box);
		stage.setScene(new Scene(root));
		stage.show();
	}
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?