Shape ক্লাস থেকে উত্তরাধিকার
জাভাFX-এ javafx.scene.text.Text ক্লাস Shape ক্লাস থেকে উত্তরাধিকার পায়, তাই এর সব মেম্বার ব্যবহার করা যায়। টেক্সট নোডের স্ট্রোক এবং কালার মডিফাই করতে stroke, stroke width এবং fill প্রপার্টি ব্যবহার করা হয়।
- Stroke Width - আকৃতির বাউন্ডারি লাইনের প্রস্থ। setStrokeWidth() মেথড দিয়ে সেট করা হয়।
- Fill - আকৃতির অভ্যন্তরীণ এলাকার রঙ। setFill() মেথড দিয়ে সেট করা হয়।
- Stroke - আকৃতির বাউন্ডারির রঙ। setStroke() মেথড দিয়ে সেট করা হয়।
উদাহরণ
import java.io.FileNotFoundException;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import javafx.scene.text.Font;
import javafx.scene.text.FontPosture;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
public class SettingStroke_Color extends Application {
public void start(Stage stage) throws FileNotFoundException {
// Creating a text object
String str = "Welcome to Tutorialspoint";
Text text = new Text(30.0, 80.0, str);
// Setting the font
Font font = Font.font("Brush Script MT", FontWeight.BOLD, FontPosture.REGULAR, 65);
text.setFont(font);
// Setting the color of the text
text.setFill(Color.BROWN);
// Setting the width
text.setStrokeWidth(2);
// Setting the stroke color
text.setStroke(Color.BLUE);
// Setting the stage
Group root = new Group(text);
Scene scene = new Scene(root, 595, 150, Color.BEIGE);
stage.setTitle("Stroke And Color");
stage.setScene(scene);
stage.show();
}
public static void main(String args[]){
launch(args);
}
}
আউটপুট
