ফিল প্রপার্টি যে রঙ দিয়ে আকৃতির অভ্যন্তরীণ অংশটি পূরণ করতে হবে তা নির্দিষ্ট/সংজ্ঞায়িত করে। আপনি fill() ব্যবহার করে পছন্দসই রঙ দিয়ে একটি নির্দিষ্ট আকৃতি পূরণ করতে পারেন javafx.scene.shape.shape এর পদ্ধতি ক্লাস।
ডিফল্টরূপে, আকার (বস্তু) লাইন, পাথ এবং পলিলাইনের জন্য এই বৈশিষ্ট্যের মান হল রঙ। কালো এবং, বাকি সমস্ত আকারের জন্য এই সম্পত্তির ডিফল্ট মান শূন্য, অর্থাৎ এগুলি কোনো রঙ দিয়ে পূর্ণ হবে না (এগুলি অস্বচ্ছ থাকবে)।
উদাহরণ
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.shape.Line;
import javafx.scene.shape.Polygon;
import javafx.scene.text.Font;
import javafx.scene.text.FontPosture;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import javafx.stage.Stage;
public class FillExample extends Application {
public void start(Stage stage) {
Font font = Font.font("verdana", FontWeight.BOLD, FontPosture.REGULAR, 12);
Text label1 = new Text("Fill: Default");
label1.setFont(font);
label1.setX(260.0);
label1.setY(125.0);
Polygon rhombus1 = new Polygon(300.0, 0.0, 250.0, 50.0, 300.0, 100.0, 350.0, 50.0);
Text label2 = new Text("Filling Line");
label2.setFont(font);
label2.setX(60.0);
label2.setY(275.0);
//Constructing a line
Line line = new Line();
line.setStartX(50.0);
line.setStartY(200.0);
line.setEndX(150.0);
line.setEndY(200.0);
line.setStrokeWidth(10.0);
line.setFill(Color.DARKBLUE);
Text label3 = new Text("Fill: Blue");
label3.setFont(font);
label3.setX(270.0);
label3.setY(275.0);
Polygon rhombus3 = new Polygon(300.0, 150.0, 250.0, 200.0, 300.0, 250.0, 350.0, 200.0);
rhombus3.setFill(Color.BLUE);
Text label4 = new Text("Fill: Chocolate");
label4.setFont(font);
label4.setX(440.0);
label4.setY(275.0);
Polygon rhombus4 = new Polygon(490.0, 150.0, 440, 200.0, 490.0, 250.0, 540.0, 200.0);
rhombus4.setFill(Color.CHOCOLATE);
//Creating a Group object
Group root = new Group(label1, label2, label3, label4, rhombus1, line, rhombus3, rhombus4);
//Creating a scene object
Scene scene = new Scene(root, 595, 310);
//Setting title to the Stage
stage.setTitle("Fill Example");
//Adding scene to the stage
stage.setScene(scene);
//Displaying the contents of the stage
stage.show();
}
public static void main(String args[]){
launch(args);
}
} আউটপুট
