IM NEW IN JAVA...COULD ANYONE HELP ME FOR MY PROJECT...IM DOING NOTEPAD SYSTEM WITH ENCRYPT AND DECRYPT USING MORSE CODE SIGNAL...CAN ANYONE ADD FOR ME FONT Jjava code AS WAT THE WINDOW NOTEPAD HAS...PLS....THIS IS MY CODE



//** NotePad using Java Which supports encryption and decryption



//** Java Packages
import java.io.*;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.text.*;
import javax.swing.event.*;

//**Main Class
public class Latest
{
public static void main (String[] args)
{
new JMenuExample();
}
} // End of Main Class


//**Class JMenuExample
class JMenuExample extends JFrame implements ActionListener
{
//**Defines Menu & Menu items.
JMenu fileJMenu = new JMenu ("File");
JMenu editJMenu = new JMenu("Edit");
JMenu viewJMenu = new JMenu("View");
JMenu aboutJMenu = new JMenu("About");

JMenuItem newJMenuItem = new JMenuItem("New");
JMenuItem openJMenuItem = new JMenuItem("Open");
JMenuItem saveJMenuItem = new JMenuItem("Save");
JMenuItem saveasJMenuItem = new JMenuItem("Save as");
JMenuItem quitJMenuItem = new JMenuItem("Quit");
JMenuItem encryptJMenuItem = new JMenuItem("Encrypt");
JMenuItem decryptJMenuItem = new JMenuItem("Decrypt");
JMenuItem decryptusercodeJMenuItem = new JMenuItem("Decrypt User Code");
JMenuItem findJMenuItem = new JMenuItem("Find");
JMenuItem replaceJMenuItem = new JMenuItem("Replace");
JMenuItem wordJMenuItem = new JMenuItem("Word Count");
JMenuItem specificJMenuItem = new JMenuItem("Specific Word Count");
JMenuItem helpJMenuItem = new JMenuItem("Help");
JMenuItem personalJMenuItem = new JMenuItem("Personal Information");

JTextArea outputArea = new JTextArea();
JScrollPane mScrollPane = new JScrollPane();
JFileChooser mJFileChooser = new JFileChooser();
int flag;
Doc mDocument;
String mWord;
String mSource[]={"a","b","c","d","e","f","g","h","i","j","k","l", "m","n",
"o","p","q","r","s","t","u","v","w","x","y","z ",
"0","1","2","3","4","5","6","7","8","9","+",", "};
String mDestination[]={" - "," - "," -- "," - "," "," - "," -- "," " /*A to H*/
," "," --- "," -- "," - "," -- "," - "," --- "," -- "/*I to P*/
," --- "," - "," "," - "," - "," - "," -- "," -- "," --- "," -- "/*Q to Z*/
," ----- "," ---- "," --- "," -- "," - "," "," - "," -- "," --- "," ---- "/*0 to9*/
," --- "," ---- "};/*Period & Comma*/

//** Constructor JMenuExample
//** Here declares Container, Menu bar, Menu Items such as New, Open etc.
public JMenuExample()
{
super ("Parthiban Notepad with Encryption and Decryption");
setSize(450,450);

//**Defining Container and adding scroll pane to it.
Container container=getContentPane();
container.add(mScrollPane, BorderLayout.CENTER);
mScrollPane.getViewport().add(outputArea, null);

//**Definging Menu bar and adding menu items to it.
JMenuBar m =new JMenuBar();
setJMenuBar(m);

m.add(fileJMenu);
m.add(editJMenu);
m.add(viewJMenu);
m.add(aboutJMenu);

fileJMenu.add(newJMenuItem);
fileJMenu.add(openJMenuItem);
fileJMenu.addSeparator();
fileJMenu.add(saveJMenuItem);
fileJMenu.add(saveasJMenuItem);
fileJMenu.addSeparator();
fileJMenu.add(quitJMenuItem);

editJMenu.add(findJMenuItem);
editJMenu.add(replaceJMenuItem);
editJMenu.addSeparator();
editJMenu.add(encryptJMenuItem);
editJMenu.add(decryptJMenuItem);
editJMenu.addSeparator();
editJMenu.add(decryptusercodeJMenuItem);


viewJMenu.add(wordJMenuItem);
viewJMenu.addSeparator();
viewJMenu.add(specificJMenuItem);

aboutJMenu.add(helpJMenuItem);
aboutJMenu.addSeparator();
aboutJMenu.add(personalJMenuItem);

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
show();
mDocument=new Doc();

//**Listner calling for quit menu item.
quitJMenuItem.addActionListener(this);

//**Listener for new menu item.
newJMenuItem.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{ flag = 0;
mDocument.mFileName="";
mDocument.text="";
outputArea.setText(mDocument.text);
setTitle(mDocument.mFileName+"Untitled-Notepad");

}
});

//**Listener for open menu item.
openJMenuItem.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{ flag = 1;
if (JFileChooser.APPROVE_OPTION == mJFileChooser.showOpenDialog(null))
{
mDocument.mFileName = mJFileChooser.getSelectedFile().getPath();
mDocument.openFile ();
outputArea.setText(mDocument.text);
setTitle(mDocument.mFileName+"-Notepad");
}
}
});

//**Listener for save menu item.
saveJMenuItem.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
if (flag ==0)
{
if (JFileChooser.APPROVE_OPTION == mJFileChooser.showSaveDialog(null))
{
flag=1;
mDocument.mFileName = mJFileChooser.getSelectedFile().getPath();
mDocument.text= outputArea.getText();
mDocument.saveToFile ();
setTitle( mDocument.mFileName);
}

}
else
{
mDocument.mFileName = mJFileChooser.getSelectedFile().getPath();
mDocument.text= outputArea.getText();
mDocument.saveToFile ();
setTitle( mDocument.mFileName);
}
}


});


//**Listener for saveas menu item.
saveasJMenuItem.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
if (JFileChooser.APPROVE_OPTION == mJFileChooser.showSaveDialog(null))
{
flag =1;
mDocument.mFileName = mJFileChooser.getSelectedFile().getPath();
mDocument.text= outputArea.getText();
mDocument.saveToFile ();
setTitle(mDocument.mFileName);
}
}
});


//**Listener for find menu item.
findJMenuItem.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
int mIndex=0;
mDocument.text=outputArea.getText();
do
{
mWord = JOptionPane.showInputDialog("Enter a word to be found:",mWord);
if (mWord==null)
{
return;
}
if (mWord.compareTo("")==0)
{
return;
}
mIndex=mDocument.text.indexOf(mWord,mIndex);
if (mIndex==-1)
{
JOptionPane.showMessageDialog(null,"Not Found."
,"Find",JOptionPane.ERROR_MESSAGE);
}
else
{
outputArea.setSelectionStart(mIndex);
mIndex=mIndex+mWord.length();
outputArea.setSelectionEnd(mIndex);
}


}
while (true);
}
});

//**Listener for replace menu item.
replaceJMenuItem.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
int mIndex=0,mOption,mCount;
String mWord1,mWord2;
mDocument.text=outputArea.getText();
mWord1 = JOptionPane.showInputDialog("Enter the word to be replaced:");
if (mWord1==null)
{
return;
}
if (mWord1.compareTo("")==0)
{
return;
}
mWord2 = JOptionPane.showInputDialog("Replace all " + mWord1 + " to:");
if (mWord2==null)
{
return;
}
if (mWord2.compareTo("")==0)
{
return;
}
mCount=mDocument.specifiedWordCount(mWord1);
if (mCount==0)
{
JOptionPane.showMessageDialog(null,"Not Found.","",JOptionPane.ERROR_MESSAGE);
return;
}
mOption=JOptionPane.showConfirmDialog(null,"Are you sure to replace all"
+ " " + mWord1 + " 's with " + mWord2 + " ?");
if (mOption==JOptionPane.YES_OPTION)
{
mDocument.replace(mWord1,mWord2);
outputArea.setText(mDocument.text);
JOptionPane.showMessageDialog(null," Replacement done.");
}
}
});


//**Listener for encrypt menu item.
encryptJMenuItem.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
mDocument.text= outputArea.getText();
mDocument.encrypt(mSource,mDestination);
outputArea.setText(mDocument.text);
}
});

//**Listener for decrypt menu item.
decryptJMenuItem.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
mDocument.text= outputArea.getText();
mDocument.encrypt(mDestination,mSource);
outputArea.setText(mDocument.text);
}
});

//**Listener for word count menu item.
wordJMenuItem.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
mDocument.text=outputArea.getText();
JOptionPane.showMessageDialog(null
,"Number of Words = " + mDocument.wordCount()
,"Word Count",JOptionPane.INFORMATION_MESSAGE);
}
});

//**Listener for specific word count menu item.
specificJMenuItem.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
mDocument.text=outputArea.getText();
mWord = JOptionPane.showInputDialog(null,"Enter the word :",mWord,JOptionPane.DEFAULT_OPTION);
if (mWord==null)
{
return;
}
if (mWord.compareTo("")==0)
{
return;
}
JOptionPane.showMessageDialog(null
,"Number of " + mWord + "'s = " + mDocument.specifiedWordCount(mWord)
,"Specified Word Count",JOptionPane.INFORMATION_MESSAGE);
}
});

//**Listener for personal menu item.
personalJMenuItem.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
JOptionPane.showMessageDialog(null,"This is a Java Program written by PARTHIBAN,\nStudent UEL Program,\nfor the Project.","Personal Information",JOptionPane.INFORMATION_MESSAGE);
}
});

//**Listener for help menu item.
helpJMenuItem.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
JOptionPane.showMessageDialog(null, "New will makes a new Text Area.\nOpen opens the documents in the System.\nSave will saves the data.\nQuit will quit the text editor.\nFind will hels to find a particular word which user key's in.\nReplace, replaces the word with another word(user key's in both words).\nWord count give the number of words used.\nSpecific word count gives the number of times a particular word used in a particular document(User can key in the word).\nEncrypt will encrypt the text with 'Morse Code'.\nDecrypt will decrypt it back to text.", "Help",JOptionPane.INFORMATION_MESSAGE);


}
});




}

//**Method actionPerformed for the quit action listener.
public void actionPerformed(ActionEvent event)
{
if(event.getSource() == quitJMenuItem)
{
int mOption = JOptionPane.showConfirmDialog(null, "Are you sure to Quit?");
if(mOption == JOptionPane.YES_OPTION)
System.exit(0);
}

}

}

//**Class document
class Doc
{
String text;
String mFileName;
int hasChanged;

//**Constructor openFile.
void openFile ()
{
try
{
File myFile = new File (mFileName);
char[] myCharSet = new char[(int)myFile.length()];
int n = 0;
FileReader myFileReader = new FileReader(myFile);
while(myFileReader.ready())
{
n += myFileReader.read(myCharSet, n, (int)myFile.length() - n);
}
myFileReader.close();
text=new String(myCharSet, 0, n);
hasChanged = 0;
}
catch (IOException e)
{
System.out.println("Error in reading document");
}
}


//**Constructor saveToFile.
void saveToFile ()
{
try
{
File myFile = new File (mFileName);
FileWriter myFileWriter = new FileWriter(myFile);
myFileWriter.write(text);
myFileWriter.close();
hasChanged = 0;
}
catch (IOException e)
{
System.out.println("Error in saving document");
}
}



//**Constructor wordCount.
int wordCount()
{
Doc newDoc=new Doc();
newDoc.text=text.trim();
if (newDoc.text.length()==0) {return 0;
}
newDoc.replace("\n"," ");
newDoc.replace("\t"," ");
int n=newDoc.specifiedWordCount(" ")-newDoc.specifiedWordCount(" ")+1;
return n;
}

int specifiedWordCount(String specifiedWord){return specifiedWordCount(specifiedWord,true);
}

int specifiedWordCount(String specifiedWord,boolean ignoreCase)
{
int n1=text.length();
int n2=specifiedWord.length();
String subs;
int n=0;
for (int i=0;i<=(n1-n2);i++)
{
subs=text.substring(i,i+n2);
if (ignoreCase)
{
if (subs.compareToIgnoreCase(specifiedWord)==0)
{
n++;
}
}
else
{
if (subs.compareTo(specifiedWord)==0)
{
n++;
}
}
}
return n;
}

//**Constructor replace.
void replace(String s1,String s2)
{
replace(s1,s2,true);
}


void replace(String s1,String s2,boolean ignoreCase)
{
int n1=s1.length();
int n2=s2.length();
String sub1,sub2;
String subs;
for (int i=0;i<=(text.length()-n1);i++)
{
subs=text.substring(i,i+n1);
if (ignoreCase)
{
if (subs.compareToIgnoreCase(s1)==0)
{
sub1=text.substring(0,i);
sub2=text.substring(i+n1,text.length());
text=sub1+s2+sub2;
}
}
else
{
if (subs.compareTo(s1)==0)
{
sub1=text.substring(0,i);
sub2=text.substring(i+n1,text.length());
text=sub1+s2+sub2;
}
}
}
}

//**Constructor encrypt.
void encrypt (String[] mSource,String[] mDestination)
{
int i;
for(i=0;i<mSource.length ;i++)
{
replace (mSource[i],mDestination[i]);
}
}
}