import javafx.application.Application;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.collections.ObservableList;
import javafx.geometry.Insets;
import javafx.scene.control.Button;
import javafx.scene.layout.VBox;
import javafx.scene.layout.Priority;
public class Main extends Application {
public void start(Stage stage) {
// في النافذة Root Node و الذي ننوي جعله الـ VBox هنا قمنا بإنشاء كائن من الكلاس
// root هنا قمنا بإنشاء جميع الأشياء التي سنضيفها في الكائن
Button button1 = new Button("Button 1");
Button button2 = new Button("Button 2");
// و هو كل المساحة المتوفرة بالطول و العرض button1 هنا قمنا بتحديد الحجم الأقصى المفضل للكائن
button1.setMaxWidth(Double.MAX_VALUE);
button2.setMaxWidth(Double.MAX_VALUE);
// و هو كل المساحة المتوفرة بالطول و العرض button2 هنا قمنا بتحديد الحجم الأقصى المفضل للكائن
button1.setMaxHeight(Double.MAX_VALUE);
button2.setMaxHeight(Double.MAX_VALUE);
// الذي سيتم وضعه بداخله VBox ثابت و لا يتأثر أبداً بحجم كائن الـ button1 هنا جعلنا طول الكائن
HBox.setHgrow(button1, Priority.NEVER);
// الذي سيتم وضعه بداخله VBox يكبر لأقصى حدود ممكنة نسبة لحجم كائن الـ button2 هنا جعلنا طول الكائن
HBox.setHgrow(button2, Priority.ALWAYS);
// VBox و الذي سيظهر عند إضافتهما في button2 و button1 هنا قمنا بإضافة هامش حول الكائنين
VBox.setMargin(button1, new Insets(10, 10, 5, 10));
VBox.setMargin(button2, new Insets(5, 10, 10, 10));
// root و الذي بدوره سيضيفهم أيضاً في الكائن في الكائن button2 و button1 هنا قمنا بإضافة الكائنات
root.getChildren().add(button1);
root.getChildren().add(button2);
// فيها و تحديد حجمها 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.collections.ObservableList;
import javafx.geometry.Insets;
import javafx.scene.control.Button;
import javafx.scene.layout.VBox;
import javafx.scene.layout.Priority;
public class Main extends Application {
@Override
public void start(Stage stage) {
// في النافذة Root Node و الذي ننوي جعله الـ VBox هنا قمنا بإنشاء كائن من الكلاس
VBox root = new VBox();
// root هنا قمنا بإنشاء جميع الأشياء التي سنضيفها في الكائن
Button button1 = new Button("Button 1");
Button button2 = new Button("Button 2");
// و هو كل المساحة المتوفرة بالطول و العرض button1 هنا قمنا بتحديد الحجم الأقصى المفضل للكائن
button1.setMaxWidth(Double.MAX_VALUE);
button2.setMaxWidth(Double.MAX_VALUE);
// و هو كل المساحة المتوفرة بالطول و العرض button2 هنا قمنا بتحديد الحجم الأقصى المفضل للكائن
button1.setMaxHeight(Double.MAX_VALUE);
button2.setMaxHeight(Double.MAX_VALUE);
// الذي سيتم وضعه بداخله VBox ثابت و لا يتأثر أبداً بحجم كائن الـ button1 هنا جعلنا طول الكائن
HBox.setHgrow(button1, Priority.NEVER);
// الذي سيتم وضعه بداخله VBox يكبر لأقصى حدود ممكنة نسبة لحجم كائن الـ button2 هنا جعلنا طول الكائن
HBox.setHgrow(button2, Priority.ALWAYS);
// VBox و الذي سيظهر عند إضافتهما في button2 و button1 هنا قمنا بإضافة هامش حول الكائنين
VBox.setMargin(button1, new Insets(10, 10, 5, 10));
VBox.setMargin(button2, new Insets(5, 10, 10, 10));
// root و الذي بدوره سيضيفهم أيضاً في الكائن في الكائن button2 و button1 هنا قمنا بإضافة الكائنات
root.getChildren().add(button1);
root.getChildren().add(button2);
// فيها و تحديد حجمها 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);
}
}