I have developed simple notepad application in java . When I want to save file I want to add .txt extension to that file. This is working fine in file dialog
String filename;
FileDialog fd = new FileDialog(Editor.this,"Save File",FileDialog.SAVE);
fd.show();
if (fd.getFile()!=null)
{
filename = fd.getDirectory() + fd.getFile()+".txt";
setTitle(filename);
}
It's working fine in the FileDialog with finename.txt
But when I take
String filename;
JFileChooser save = new JFilechooser();
Try to add extension
filename =save.getDirectory() + save.getFile()+".txt";
It's not working how can i solve this issue?