কম্পিউটার টিউটোরিয়াল

জাভাFX-এ টেক্সটে স্ট্রোক (stroke) এবং কালার যোগ করা

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); 
    } 
}

আউটপুট

জাভাFX-এ টেক্সটে স্ট্রোক (stroke) এবং কালার যোগ করা

  1. জাভাতে JLabel টেক্সটকে ভিন্ন রঙ ও ফন্টে কীভাবে বাস্তবায়ন করবেন?

  2. Word-এ ব্যাকগ্রাউন্ড কালার পরিবর্তন এবং Drop Caps যোগ করার পদ্ধতি

  3. Windows 11/10-এ Microsoft Paint-এ টেক্সট যোগ করা এবং ফন্ট রঙ পরিবর্তন করা

  4. আইফোন গ্রুপ মেসেজিং মেনে নিন: iMessage গ্রুপে পার্টিশিপ্যান্ট যোগ ও অপসারণ