Hi..I'm currently working on linguistic area which i want to develope a grammar checker..The problem is i don't have any idea which library (if any) that i need to use..here is the code...


import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.util.Scanner;
import javax.swing.JFileChooser.*;
import java.io.*;
import javax.swing.filechooser.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.SwingUtilities;

import javax.swing.text.*;
import javax.swing.BorderFactory;
import javax.swing.table.*;
import java.util.Comparator;
import java.awt.GraphicsEnvironment;


public class Grammar extends JFrame implements ActionListener
{
private JMenuItem jmiOpen, jmiExit, jmiAbout;
private JButton check = new JButton ("Check Grammar");
private JButton clear = new JButton ("Clear Text");

private JTextArea jtaOpen = new JTextArea();
private JTextArea jtaError = new JTextArea();

private JLabel jlblStatus = new JLabel();
private JPanel jpc = new JPanel();
private JFileChooser jFileChooser = new JFileChooser();
private Map map = new TreeMap();
private String delim = " \t\n.,:;?!-/()[]\"\'1234567890 ";


public Grammar()
{
setTitle("Malay Grammar Checker");
setSize(500,500);

JMenuBar menuBar = new JMenuBar();
setJMenuBar(menuBar);

JMenu fileMenu = new JMenu("File");
JMenu helpMenu = new JMenu("Help");
fileMenu.setMnemonic('F');
helpMenu.setMnemonic('H');
menuBar.add(fileMenu);
menuBar.add(helpMenu);



fileMenu.add(jmiOpen = new JMenuItem("Open",'O'));
fileMenu.add(jmiExit = new JMenuItem("Exit",'E'));
helpMenu.add(jmiAbout = new JMenuItem("About Grammar Checker",'A'));


jmiOpen.addActionListener(this);
jmiExit.addActionListener(this);
jmiAbout.addActionListener(this);


jFileChooser.setCurrentDirectory(new File("."));


jtaOpen.setLineWrap(true);
jtaOpen.setWrapStyleWord(true);
jtaOpen.setEditable(true);
JScrollPane areaScrollPane = new JScrollPane(jtaOpen);
areaScrollPane.setVerticalScrollBarPolicy(JScrollP ane.VERTICAL_SCROLLBAR_ALWAYS);
areaScrollPane.setPreferredSize(new Dimension(500,200));
areaScrollPane.setBorder(BorderFactory.createCompo undBorder(
BorderFactory.createCompoundBorder(BorderFactory
.createTitledBorder("Display Text"), BorderFactory
.createEmptyBorder(8, 8, 8, 8)), areaScrollPane
.getBorder()));
JPanel p1 = new JPanel(new BorderLayout());
p1.add( areaScrollPane, BorderLayout.EAST);
add(p1, BorderLayout.LINE_START);


JPanel p2 = new JPanel();
p2.add(check);
check.setToolTipText("Check The Grammar");
check.addActionListener(new ActionListener()

{
public void actionPerformed(ActionEvent e)
{

jtaOpen.setLineWrap(true);
}
});

p2.add(clear);
clear.setToolTipText("Clear open text");
clear.addActionListener(new ActionListener()

{
public void actionPerformed(ActionEvent e)
{
jtaOpen.setText("");
}
});


Container c = getContentPane();
c.add(p2, BorderLayout.SOUTH);


}


public void actionPerformed(ActionEvent e)
{

String actionCommand = e.getActionCommand();

if (e.getSource() instanceof JMenuItem)
{


if("Open".equals(actionCommand))
open();


else if ("Exit".equals(actionCommand))


System.exit(0);

}

// 'Help' menu events
if ( jmiAbout == e.getSource() ) {
JOptionPane.showMessageDialog(Grammar.this,
"Malay Grammar Checker", JOptionPane.PLAIN_MESSAGE );
}
}

private void open()
{
if (jFileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION)
{
jtaOpen.setText("");
open(jFileChooser.getSelectedFile());
createMap();
}
}


private void open(File file)
{
try
{
//--------------------------------------------READ FROM SPECIFIED FILE AND STORE IT IN jta
BufferedInputStream in = new BufferedInputStream(new FileInputStream(file));
byte[] b = new byte[in.available()];
in.read(b, 0, b.length);
jtaOpen.append(new String(b, 0, b.length));
in.close();

//------------------------------------------DISPLAY STATUS OF OPEN FILE OPERATION IN jlblStatus
jlblStatus.setText(file.getName() + "Opened");
}
catch (IOException ex)
{
jlblStatus.setText("Error opening" + file.getName());
}
}



private void createMap() //uses a map to store the number of occurrences of each word in sentences
{
String open = jtaOpen.getText(); //obtain user input
StringTokenizer tokenizer = new StringTokenizer(open, delim); //tokenizes the string
map = new TreeMap();
while (tokenizer.hasMoreTokens())
{
//converts the and lover case, trim, next token
String word = tokenizer.nextToken().toLowerCase().trim();

if(!word.equals(""))// to check whether is empty
{
if ( map.containsKey(word))//if map contains the word
{
Integer count = (Integer) map.get(word);
//------------------increment value
map.put(word, new Integer(count.intValue() + 1 ));
}
else
{
map.put(word, new Integer(1));
}
}

}

}


public static void main(String[] args) throws Exception
{
Grammar g = new Grammar();
g.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
g.setVisible(true);
}
}