টেক্সট নোড তৈরি করা
জাভাFX-এ টেক্সট নোড রিপ্রেজেন্ট করা হয় javafx.scene.text.Text ক্লাস দিয়ে। জাভাFX উইন্ডোতে টেক্সট দেখানোর জন্য:
- Text ক্লাস ইনস্ট্যানশিয়েট করুন।
- সেটার মেথড বা কনস্ট্রাক্টর আর্গুমেন্ট দিয়ে পজিশন এবং টেক্সট স্ট্রিং সেট করুন।
- তैयার নোডটি Group অবজেক্টে যোগ করুন।
স্ট্রাইকথ্রু (Strikethrough)
strikethrough প্রপার্টি নির্ধারণ করে টেক্সটের প্রতিটি লাইনের মাঝপথে একটি সোজা রেখা থাকবে কিনা। setStrikeThrough(true) দিয়ে সক্রিয় করা যায়।
আন্ডারলাইন (Underline)
underline প্রপার্টি নির্ধারণ করে টেক্সটের প্রতিটি লাইনের নিচে একটি সোজা রেখা থাকবে কিনা। setUnderline(true) দিয়ে সক্রিয় করা যায়।
উদাহরণ
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 Underline_StrikeThrough 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.DARKCYAN);
// Setting the width and color of the stroke
text.setStrokeWidth(2);
text.setStroke(Color.DARKSLATEGRAY);
// Underlining the text
text.setUnderline(true);
// Striking through the text
text.setStrikethrough(true);
// Setting the stage
Group root = new Group(text);
Scene scene = new Scene(root, 595, 150, Color.BEIGE);
stage.setTitle("Underline And Strike-through");
stage.setScene(scene);
stage.show();
}
public static void main(String args[]){
launch(args);
}
}
আউটপুট
