/ Published in: Java
A Swing ActionListener that opens a JFileChooser and returns the selected file.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/** This action creates and shows a modal save-file dialog. */ this.parent = parent; } // Show dialog; won't return until dialog is closed: chooser.showSaveDialog(parent); // Get the selected file if (file != null) { handleFile(file); } } } ... myButton.addActionListener(new FileAction(getMainPanel()) { // do whatever you want with the file... } });