JavaFXطريقة تحديد قيمة الـProgressIndicator
المثال التالي يعلمك طريقة تحديد قيمة الـ ProgressIndicator.
مثال
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.ProgressIndicator;
import javafx.stage.Stage;
public class Main extends Application {
@Override
public void start(Stage stage) {
// مع تحديد القيمة الأولية لكل واحد منهم ProgressIndicator هنا قمنا بإنشاء 5 كائنات من الكلاس
ProgressIndicator progressIndicator_1 = new ProgressIndicator(0.0);
ProgressIndicator progressIndicator_2 = new ProgressIndicator(0.25);
ProgressIndicator progressIndicator_3 = new ProgressIndicator(0.5);
ProgressIndicator progressIndicator_4 = new ProgressIndicator(0.75);
ProgressIndicator progressIndicator_5 = new ProgressIndicator(1.0);
// هنا قمنا بتحديد حجم الأشياء التي سنضيفها في النافذة
progressIndicator_1.setPrefSize(50, 50);
progressIndicator_2.setPrefSize(50, 50);
progressIndicator_3.setPrefSize(50, 50);
progressIndicator_4.setPrefSize(50, 50);
progressIndicator_5.setPrefSize(50, 50);
// هنا قمنا بتحديد مكان ظهور الأشياء التي سنضيفها في النافذة
progressIndicator_1.setTranslateX(50);
progressIndicator_1.setTranslateY(100);
progressIndicator_2.setTranslateX(110);
progressIndicator_2.setTranslateY(100);
progressIndicator_3.setTranslateX(170);
progressIndicator_3.setTranslateY(100);
progressIndicator_4.setTranslateX(230);
progressIndicator_4.setTranslateY(100);
progressIndicator_5.setTranslateX(290);
progressIndicator_5.setTranslateY(100);
// في النافذة Root Node لأننا ننوي جعله الـ Group هنا قمنا بإنشاء كائن من الكلاس
Group root = new Group();
// root هنا قمنا بإضافة جميع الأشياء في الكائن
root.getChildren().add(progressIndicator_1);
root.getChildren().add(progressIndicator_2);
root.getChildren().add(progressIndicator_3);
root.getChildren().add(progressIndicator_4);
root.getChildren().add(progressIndicator_5);
// فيها و تحديد حجمها Node كأول root هنا قمنا بإنشاء محتوى النافذة مع تعيين الكائن
Scene scene = new Scene(root, 400, 250);
// هنا وضعنا عنوان للنافذة
stage.setTitle("JavaFX ProgressIndicator");
// أي وضعنا محتوى النافذة الذي قمنا بإنشائه للنافذة .stage في كائن الـ scene هنا وضعنا كائن الـ
stage.setScene(scene);
// هنا قمنا بإظهار النافذة
stage.show();
}
// هنا قمنا بتشغيل التطبيق
public static void main(String[] args) {
launch(args);
}
}
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.ProgressIndicator;
import javafx.stage.Stage;
public class Main extends Application {
@Override
public void start(Stage stage) {
// مع تحديد القيمة الأولية لكل واحد منهم ProgressIndicator هنا قمنا بإنشاء 5 كائنات من الكلاس
ProgressIndicator progressIndicator_1 = new ProgressIndicator(0.0);
ProgressIndicator progressIndicator_2 = new ProgressIndicator(0.25);
ProgressIndicator progressIndicator_3 = new ProgressIndicator(0.5);
ProgressIndicator progressIndicator_4 = new ProgressIndicator(0.75);
ProgressIndicator progressIndicator_5 = new ProgressIndicator(1.0);
// هنا قمنا بتحديد حجم الأشياء التي سنضيفها في النافذة
progressIndicator_1.setPrefSize(50, 50);
progressIndicator_2.setPrefSize(50, 50);
progressIndicator_3.setPrefSize(50, 50);
progressIndicator_4.setPrefSize(50, 50);
progressIndicator_5.setPrefSize(50, 50);
// هنا قمنا بتحديد مكان ظهور الأشياء التي سنضيفها في النافذة
progressIndicator_1.setTranslateX(50);
progressIndicator_1.setTranslateY(100);
progressIndicator_2.setTranslateX(110);
progressIndicator_2.setTranslateY(100);
progressIndicator_3.setTranslateX(170);
progressIndicator_3.setTranslateY(100);
progressIndicator_4.setTranslateX(230);
progressIndicator_4.setTranslateY(100);
progressIndicator_5.setTranslateX(290);
progressIndicator_5.setTranslateY(100);
// في النافذة Root Node لأننا ننوي جعله الـ Group هنا قمنا بإنشاء كائن من الكلاس
Group root = new Group();
// root هنا قمنا بإضافة جميع الأشياء في الكائن
root.getChildren().add(progressIndicator_1);
root.getChildren().add(progressIndicator_2);
root.getChildren().add(progressIndicator_3);
root.getChildren().add(progressIndicator_4);
root.getChildren().add(progressIndicator_5);
// فيها و تحديد حجمها Node كأول root هنا قمنا بإنشاء محتوى النافذة مع تعيين الكائن
Scene scene = new Scene(root, 400, 250);
// هنا وضعنا عنوان للنافذة
stage.setTitle("JavaFX ProgressIndicator");
// أي وضعنا محتوى النافذة الذي قمنا بإنشائه للنافذة .stage في كائن الـ scene هنا وضعنا كائن الـ
stage.setScene(scene);
// هنا قمنا بإظهار النافذة
stage.show();
}
// هنا قمنا بتشغيل التطبيق
public static void main(String[] args) {
launch(args);
}
}
ستظهر لك النافذة التالية عند التشغيل.