Gregg --
Thanks for the quick reply!
1. I'm using null because I don't know how to reference the parent frame. The parent frame is a class with nothing in the main method; an instance of its class gets instantiated by another class. So I'm not sure what to call it. I tried "this", and that seemed to fix the problem of the messageDialog cutting off part of the message.
2. I believe I'm only using Swing components.
3. Here's the method in which showMessageDialog is used
void dataButton_ActionPerformed(ActionEvent event)
{
File selectedFile;
File dummyFile = new File("Data.csv");
if (fileChooser2 == null) {
fileChooser2 = new JFileChooser();
FileFilter filter = new FileFilter() {
public boolean accept(File f) {
String fn = f.getName();
if (fn.endsWith(".csv") || f.isDirectory()) return true;
else return false;
} //end accept
public String getDescription() { return "Comma-separated Value Files (*.csv)"; }
}; //end filter
fileChooser2.setSelectedFile(dummyFile);
fileChooser2.setFileFilter(filter);
fileChooser2.addChoosableFileFilter(filter);
} //end if
int result = fileChooser2.showSaveDialog(this);
if (result == JFileChooser.APPROVE_OPTION) {
selectedFile = fileChooser2.getSelectedFile();
if (selectedFile.getName().endsWith(".csv")) {
//code to run if true
String dataMessage = new String("Your data has been saved as " + selectedFile.getName());
JOptionPane.showMessageDialog(null, dataMessage );
} //end if
else { JOptionPane.showMessageDialog(null, "The filename must end with '.csv'", "Save File Error", JOptionPane.ERROR_MESSAGE); }
} //end if
} //end dataButton_ActionPerformed
Thanks in advance,
Chris