Today I am sharing with you another important topic where I will give you an example by which you will get a clear idea about how to read or search any Bengali or Bangla font from a text pad (notepad) or file and then show it in JTextField. This code is important for those who are trying to prepare English to Bengali Dictionary. Download the reader.txt which I have used here to read Bengali (Bangla) words.
Code Example: simple.java
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.JButton;
import javax.swing.JPanel;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JTextField;
import java.awt.BorderLayout;
import java.io.*;
import java.util.*;
public class simple extends JFrame
{
private Toolkit toolkit;
JTextField text1,text2;
String conversion;
public simple()
{
int xpos;
int ypos;
Font displayFont=new Font(“Times New Roman”, Font.BOLD,14);
Font displayFont1=new Font(“SutonnyMJ”, Font.BOLD,14);
setSize(300,150);
setTitle(“English To Bengali Dictionary”);
setDefaultCloseOperation(EXIT_ON_CLOSE);
JPanel panel=new JPanel();
getContentPane().add(panel);
panel.setLayout(null);
toolkit=getToolkit();
Dimension size=toolkit.getScreenSize();
setLocation(size.width/2-getWidth()/2, size.height/2-getHeight()/2);
xpos=getWidth()/2;
System.out.println(size);
System.out.println(xpos);
JButton beep;
text1=new JTextField();
text2=new JTextField();
beep= new JButton(“Click”);
beep.setFont(displayFont);
text2.setFont(displayFont1);
beep.setBounds(204,49,80,30);
text1.setBounds(50,20,150,30);
text2.setBounds(50,80,150,30);
beep.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
try
{
int tokencount;
FileReader fr=new FileReader(“reader.txt”);
BufferedReader br=new BufferedReader(fr);
String s;
int linecount=0;
String line;
String words[]=new String[500];
int indexfound;
while ((s=br.readLine())!=null )
{
linecount++;
conversion = new String(text1.getText());
indexfound=s.indexOf(conversion);
if (indexfound>-1)
{
System.out.println(“Word was found at position” +indexfound+ “on line”+linecount);
line=s;
System.out.println(line);
int idx=0;
String[] arr= line.split(“=”);
System.out.println(“Array :” +arr.length );
for (idx=0;idx<arr.length;idx++)
{
words[idx]=arr[idx];
String gg =words[idx];
System.out.println(“Word Length:”+gg.length());
System.out.println(“COnversion Length:”+conversion.length());
if (conversion.length()==(gg.length()-1))
{
System.out.println(words[idx]);
text2.setText(arr[1]);
}}}}
fr.close();
}
catch (IOException e){}
}});
panel.add(beep);
panel.add(text1,BorderLayout.CENTER);
panel.add(text2,BorderLayout.WEST);
}
public static void main(String args[])
{
simple x=new simple();
x.setVisible(true);
}}

English To Bangla Dictionary
Sir,
It was not possible to download the reader.txt file.Please,send me the proper link in replay or my email address.
Thank you in advance.
sent