Handling menu events

Dear all, i have created a text editor with menus as those given in a notepad application. i have created the following codes on how to save a file.FileDialog fd2 = new FileDialog (this, "Save file", FileDialog.SAVE);FileWriter fw; if(ae.getActionCommand().equals("Save")) { fd2.setVisible(true);String st,sn; try { sn= nt.fd2.getDirectory()+"/"+nt.fd2.getFile()+".txt"; fw = new FileWriter(sn); char ch; String stt=nt.t.getText(); for(int i=0;i<stt.length();i++) { ch=stt.charAt(i); fw.write(ch);

} but everytime i click on the save menu the save as dialog box appears even though the file has been saved already, can anyone help me out with the code so that if the file has been saved already the 'save as' dialog box should not reappear but just save the latest changes made. Thanx.