import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.stage.Stage;
import javafx.scene.layout.AnchorPane;
public class Main extends Application {
public void start(Stage stage) {
// في النافذة Root Node و الذي ننوي جعله الـ AnchorPane هنا قمنا بإنشاء كائن من الكلاس
AnchorPane root = new AnchorPane();
// root هنا قمنا بإنشاء جميع الأشياء التي سنضيفها في الكائن
Button button1 = new Button("Button 1");
Button button2 = new Button("Button 2");
Button button3 = new Button("Button 3");
// الذي سيوضع بداخله AnchorPane و كائن الـ button هنا قمنا بتحديد حجم الفراغ من الأعلى, اليسار و اليمين بين الكائن
AnchorPane.setTopAnchor(button1, 30.0);
AnchorPane.setRightAnchor(button1, 30.0);
AnchorPane.setLeftAnchor(button1, 30.0);
// ثابت و يساوي 30 بيكسل فقط كحد أقصى إذا كان هناك مساحة متوفرة في النافذة button1 هنا جعلنا طول الكائن
button1.setPrefHeight(30);
// الذي سيوضع بداخله AnchorPane و كائن الـ button هنا قمنا بتحديد حجم الفراغ من الأعلى, اليسار, اليمين و الأسفل بين الكائن
AnchorPane.setTopAnchor(button2, 70.0);
AnchorPane.setRightAnchor(button2, 130.0);
AnchorPane.setLeftAnchor(button2, 30.0);
AnchorPane.setBottomAnchor(button2, 30.0);
// الذي سيوضع بداخله AnchorPane و كائن الـ button هنا قمنا بتحديد حجم الفراغ من الأعلى, اليمين و الأسفل بين الكائن
AnchorPane.setTopAnchor(button3, 70.0);
AnchorPane.setRightAnchor(button3, 30.0);
AnchorPane.setBottomAnchor(button3, 30.0);
// ثابت و يساوي 80 بيكسل فقط كحد أقصى إذا كان هناك مساحة متوفرة في النافذة button3 هنا جعلنا عرض الكائن
button3.setPrefWidth(80);
// root في الكائن button هنا قمنا بإضافة الكائن
root.getChildren().addAll(button1, button2, button3);
// فيها و تحديد حجمها Node كأول root هنا قمنا بإنشاء محتوى النافذة مع تعيين الكائن
Scene scene = new Scene(root, 350, 250);
// هنا وضعنا عنوان للنافذة
stage.setTitle("JavaFX AnchorPane");
// أي وضعنا محتوى النافذة الذي قمنا بإنشائه للنافذة .stage في كائن الـ scene هنا وضعنا كائن الـ
// هنا قمنا بإظهار النافذة
// هنا قمنا بتشغيل التطبيق
public static void main(String[] args) {
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.stage.Stage;
import javafx.scene.layout.AnchorPane;
public class Main extends Application {
@Override
public void start(Stage stage) {
// في النافذة Root Node و الذي ننوي جعله الـ AnchorPane هنا قمنا بإنشاء كائن من الكلاس
AnchorPane root = new AnchorPane();
// root هنا قمنا بإنشاء جميع الأشياء التي سنضيفها في الكائن
Button button1 = new Button("Button 1");
Button button2 = new Button("Button 2");
Button button3 = new Button("Button 3");
// الذي سيوضع بداخله AnchorPane و كائن الـ button هنا قمنا بتحديد حجم الفراغ من الأعلى, اليسار و اليمين بين الكائن
AnchorPane.setTopAnchor(button1, 30.0);
AnchorPane.setRightAnchor(button1, 30.0);
AnchorPane.setLeftAnchor(button1, 30.0);
// ثابت و يساوي 30 بيكسل فقط كحد أقصى إذا كان هناك مساحة متوفرة في النافذة button1 هنا جعلنا طول الكائن
button1.setPrefHeight(30);
// الذي سيوضع بداخله AnchorPane و كائن الـ button هنا قمنا بتحديد حجم الفراغ من الأعلى, اليسار, اليمين و الأسفل بين الكائن
AnchorPane.setTopAnchor(button2, 70.0);
AnchorPane.setRightAnchor(button2, 130.0);
AnchorPane.setLeftAnchor(button2, 30.0);
AnchorPane.setBottomAnchor(button2, 30.0);
// الذي سيوضع بداخله AnchorPane و كائن الـ button هنا قمنا بتحديد حجم الفراغ من الأعلى, اليمين و الأسفل بين الكائن
AnchorPane.setTopAnchor(button3, 70.0);
AnchorPane.setRightAnchor(button3, 30.0);
AnchorPane.setBottomAnchor(button3, 30.0);
// ثابت و يساوي 80 بيكسل فقط كحد أقصى إذا كان هناك مساحة متوفرة في النافذة button3 هنا جعلنا عرض الكائن
button3.setPrefWidth(80);
// root في الكائن button هنا قمنا بإضافة الكائن
root.getChildren().addAll(button1, button2, button3);
// فيها و تحديد حجمها Node كأول root هنا قمنا بإنشاء محتوى النافذة مع تعيين الكائن
Scene scene = new Scene(root, 350, 250);
// هنا وضعنا عنوان للنافذة
stage.setTitle("JavaFX AnchorPane");
// أي وضعنا محتوى النافذة الذي قمنا بإنشائه للنافذة .stage في كائن الـ scene هنا وضعنا كائن الـ
stage.setScene(scene);
// هنا قمنا بإظهار النافذة
stage.show();
}
// هنا قمنا بتشغيل التطبيق
public static void main(String[] args) {
launch(args);
}
}