class FileChooserAction extends AbstractAction {

    /**
     * A serial version UID.
     */
    private static final long serialVersionUID = 2225830878098387118L;
    /**
     * An object that is expecting the result of the file chooser action.
     */
    protected Observable observable;
    /**
     * A file filter to apply when browsing for a file.
     */
    protected FileFilter filter;
    /**
     * Indicates if you're browsing to create a new or an existing file.
     */
    protected boolean newFile;
    /**
     * The file that was chosen.
     */
    protected File file;

    /**
     * Creates a new file chooser action.
     *
     * @param observable the object waiting for you to select file
     * @param caption    a description for the action
     * @param filter     a filter to apply when browsing
     * @param newFile    indicates if you should browse for a new or existing file
     */
    public FileChooserAction(Observable observable, String caption, FileFilter filter, boolean newFile) {
        super(caption);
        this.observable = observable;
        this.filter = filter;
        this.newFile = newFile;
    }

    /**
     * Getter for the file.
     *
     * @return a file
     */
    public File getFile() {
        return file;
    }

    /**
     * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
     */
    public void actionPerformed(ActionEvent evt) {<FILL_FUNCTION_BODY>}

}

        JFileChooser fc = new JFileChooser();
        if (filter != null) {
            fc.setFileFilter(filter);
        }
        int okCancel;
        if (newFile) {
            okCancel = fc.showSaveDialog(null);
        } else {
            okCancel = fc.showOpenDialog(null);
        }
        if (okCancel == JFileChooser.APPROVE_OPTION) {
            file = fc.getSelectedFile();
            observable.notifyObservers(this);
        }
    
<methods>public void <init>() ,public void <init>(java.lang.String) ,public void <init>(java.lang.String, javax.swing.Icon) ,public synchronized void addPropertyChangeListener(java.beans.PropertyChangeListener) ,public java.lang.Object[] getKeys() ,public synchronized java.beans.PropertyChangeListener[] getPropertyChangeListeners() ,public java.lang.Object getValue(java.lang.String) ,public boolean isEnabled() ,public void putValue(java.lang.String, java.lang.Object) ,public synchronized void removePropertyChangeListener(java.beans.PropertyChangeListener) ,public void setEnabled(boolean) <variables>private static java.lang.Boolean RECONFIGURE_ON_NULL,private transient javax.swing.ArrayTable arrayTable,protected javax.swing.event.SwingPropertyChangeSupport changeSupport,protected boolean enabled