Save As/Load Dialog

In my program I write some stuff to a JTextArea, and I have a save button. When press it, it saves to a default text file. But I want a Save As dialog a la any windows prgoram to pop up, enabling to choose file name and directories etc etc. I also want to be able to do the same for loading. Can you please help me? This is how my code for saving looks right now:

JButton button2 =new JButton("Save");

button2.addActionListener(

new ActionListener()

{

publicvoid actionPerformed(ActionEvent e)

{

//JOptionPane.showMessageDialog(parentComponent, "BUTTON PRESSED!");

FileOutputStream out;

PrintStream p;

try{// Create a new file output stream

// connected to "myfile.txt"

out =new FileOutputStream("saveddata.txt");// Connect print stream to the output stream

p =new PrintStream( out );

p.println ( lolarea.getText() );

p.close();

}

catch (Exception ex){ System.err.println ("Error writing to file");

}

}

});

[1725 byte] By [nayon_7a] at [2007-11-27 6:36:36]
# 1
Use a [url= http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JFileChooser.html]JFileChooser[/url].
thomas.behra at 2007-7-12 18:04:28 > top of Java-index,Java Essentials,Java Programming...