import javafx.application.Application;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.control.Button;
import javafx.scene.layout.VBox;
public class Main extends Application {
public void start(Stage stage) {
// في النافذة Root Node و الذي ننوي جعله الـ VBox هنا قمنا بإنشاء كائن من الكلاس
// يظهر في وسطه root هنا قمنا بجعل محتوى الكائن
root.setAlignment(Pos.CENTER);
// root هنا قمنا بإنشاء جميع الأشياء التي سنضيفها في الكائن
Button button1 = new Button("Button 1");
Button button2 = new Button("Button 2");
Button button3 = new Button("Button 3");
// root و الذي سيتغير بشكل تلقائي في حال تغيير حجم الكائن root هنا قمنا بتحديد الحجم المفضل للأشياء التي سنضيفها في الكائن
button1.setPrefSize(150, 50);
button2.setPrefSize(150, 50);
button3.setPrefSize(150, 50);
// VBox هنا قمنا بإضافة هامش لكل شيء سنضيفه في الكائن
VBox.setMargin(button1, new Insets(10, 10, 10, 10)); // من جميع الجهات button1 هنا أضفنا هامش بمقدار 10 بيكسل حول الكائن
VBox.setMargin(button2, new Insets(0, 10, 0, 10)); // من اليمين و اليسار فقط button2 هنا أضفنا هامش بمقدار 10 بيكسل حول الكائن
VBox.setMargin(button3, new Insets(10, 10, 10, 10)); // من جميع الجهات button3 هنا أضفنا هامش بمقدار 10 بيكسل حول الكائن
// root في الكائن button3 و button2 و button1 هنا قمنا بإضافة الكائنات
root.getChildren().add(button1);
root.getChildren().add(button2);
root.getChildren().add(button3);
// فيها و تحديد حجمها Node كأول root هنا قمنا بإنشاء محتوى النافذة مع تعيين الكائن
Scene scene = new Scene(root, 300, 150);
// هنا وضعنا عنوان للنافذة
stage.setTitle("JavaFX VBox");
// أي وضعنا محتوى النافذة الذي قمنا بإنشائه للنافذة .stage في كائن الـ scene هنا وضعنا كائن الـ
// هنا قمنا بإظهار النافذة
// هنا قمنا بتشغيل التطبيق
public static void main(String[] args) {
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.control.Button;
import javafx.scene.layout.VBox;
public class Main extends Application {
@Override
public void start(Stage stage) {
// في النافذة Root Node و الذي ننوي جعله الـ VBox هنا قمنا بإنشاء كائن من الكلاس
VBox root = new VBox();
// يظهر في وسطه root هنا قمنا بجعل محتوى الكائن
root.setAlignment(Pos.CENTER);
// root هنا قمنا بإنشاء جميع الأشياء التي سنضيفها في الكائن
Button button1 = new Button("Button 1");
Button button2 = new Button("Button 2");
Button button3 = new Button("Button 3");
// root و الذي سيتغير بشكل تلقائي في حال تغيير حجم الكائن root هنا قمنا بتحديد الحجم المفضل للأشياء التي سنضيفها في الكائن
button1.setPrefSize(150, 50);
button2.setPrefSize(150, 50);
button3.setPrefSize(150, 50);
// VBox هنا قمنا بإضافة هامش لكل شيء سنضيفه في الكائن
VBox.setMargin(button1, new Insets(10, 10, 10, 10)); // من جميع الجهات button1 هنا أضفنا هامش بمقدار 10 بيكسل حول الكائن
VBox.setMargin(button2, new Insets(0, 10, 0, 10)); // من اليمين و اليسار فقط button2 هنا أضفنا هامش بمقدار 10 بيكسل حول الكائن
VBox.setMargin(button3, new Insets(10, 10, 10, 10)); // من جميع الجهات button3 هنا أضفنا هامش بمقدار 10 بيكسل حول الكائن
// root في الكائن button3 و button2 و button1 هنا قمنا بإضافة الكائنات
root.getChildren().add(button1);
root.getChildren().add(button2);
root.getChildren().add(button3);
// فيها و تحديد حجمها Node كأول root هنا قمنا بإنشاء محتوى النافذة مع تعيين الكائن
Scene scene = new Scene(root, 300, 150);
// هنا وضعنا عنوان للنافذة
stage.setTitle("JavaFX VBox");
// أي وضعنا محتوى النافذة الذي قمنا بإنشائه للنافذة .stage في كائن الـ scene هنا وضعنا كائن الـ
stage.setScene(scene);
// هنا قمنا بإظهار النافذة
stage.show();
}
// هنا قمنا بتشغيل التطبيق
public static void main(String[] args) {
launch(args);
}
}