java item listener

i need help regarding the save menu item i have in my menu bar. i have set the code to

private void smActionPerformed(java.awt.event.ActionEvent evt) {


}

but i am unsure what needs to go inbetween the brackets? The gui is a form where poeple fill in there medical record e.g combo box "mr/mrs" textfield "medical problems" etc and when they click file save i would like the user to get a save box (like save as box in word) and the information to be saved in a txt file.

P.S. would it be possible to have the "file type" set to save as a txt file as default.

Answers


Use JFileChooser#showSaveDialog() to ask the enduser to select a File.

JFileChooser fileChooser = new JFileChooser();
if (fileChooser.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) {
    File file = fileChooser.getSelectedFile();
    // ...
} else {
    // User pressed cancel.
}

Need Your Help

Help with AJAX and HTML

javascript html ajax

I have HTML code similar to

jni signature for method

java c++ jni

My java method contains a function

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.