Java: I want to show Bangla(Bengali) in JLabel

In my last post I have discussed about How to Read a text file and search any specific word from that.

Today I will share with you another important fact in java porgramming about how to show Bangla (Bengali) font in JLabel using java.

The Font I have used here is not an Unicode font. To show Bangla I have used SuttonyMJ font.

I have a wish to share with you in another post about Unicode font in Java.

To show Bangla in JLabel is little bit tricy. Just write the Bengali word in a MSWord file and then pest it in the JLabel.

For example: JLabel label2=new JLabel(” †`Lv,  weeiY,  Rvbv”,JLabel.CENTER);

In the code you may not see the Bengali font accurately but after running the code, Java will show you the code accurately.

Check the OUTPUT:

 JLabel Bangla font java

Code Example:

import javax.swing.*;

import java.awt.*;

class labelFont extends JFrame

{

JLabel label1=new JLabel(“see,  description,  know”,JLabel.CENTER);

JLabel label2=new JLabel(” †`Lv,  weeiY,  Rvbv”,JLabel.CENTER);

JLabel label3=new JLabel(“I like Programming and I am a beginner”);

labelFont()

{

          label1.setBounds(95,00,140,40);

          label2.setBounds(95,35,140,40);

          label3.setBounds(15,200,270,40);

          Font displayFont=new Font(“Times New Roman”,Font.PLAIN,12);

    label1.setFont(displayFont);

          Font displayFont1=new Font(“SutonnyMJ”,Font.PLAIN,16);

    label2.setFont(displayFont1);

                  setSize(300,300);

                             setTitle(“JLabel Font Change”);

                             setDefaultCloseOperation(EXIT_ON_CLOSE);

                  JPanel panel=new JPanel();

            getContentPane().add(panel);

                             panel.setLayout(null);

                             panel.add(label1);

            panel.add(label2);

            panel.add(label3);

}

public static void main(String args[])

{

labelFont myFont=new labelFont();

myFont.setVisible(true);

}

}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: