Class FileChooserAction

  • All Implemented Interfaces:
    java.awt.event.ActionListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, javax.swing.Action

    public class FileChooserAction
    extends javax.swing.AbstractAction
    Allows you to browse the file system and forwards the file to the object that is waiting for you to choose a file.
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.io.File file
      The file that was chosen.
      protected javax.swing.filechooser.FileFilter filter
      A file filter to apply when browsing for a file.
      protected boolean newFile
      Indicates if you're browsing to create a new or an existing file.
      protected java.util.Observable observable
      An object that is expecting the result of the file chooser action.
      private static long serialVersionUID
      A serial version UID.
      • Fields inherited from class javax.swing.AbstractAction

        changeSupport, enabled
      • Fields inherited from interface javax.swing.Action

        ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
    • Constructor Summary

      Constructors 
      Constructor Description
      FileChooserAction​(java.util.Observable observable, java.lang.String caption, javax.swing.filechooser.FileFilter filter, boolean newFile)
      Creates a new file chooser action.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void actionPerformed​(java.awt.event.ActionEvent evt)  
      java.io.File getFile()
      Getter for the file.
      • Methods inherited from class javax.swing.AbstractAction

        addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface javax.swing.Action

        accept
    • Field Detail

      • serialVersionUID

        private static final long serialVersionUID
        A serial version UID.
        See Also:
        Constant Field Values
      • observable

        protected java.util.Observable observable
        An object that is expecting the result of the file chooser action.
      • filter

        protected javax.swing.filechooser.FileFilter filter
        A file filter to apply when browsing for a file.
      • newFile

        protected boolean newFile
        Indicates if you're browsing to create a new or an existing file.
      • file

        protected java.io.File file
        The file that was chosen.
    • Constructor Detail

      • FileChooserAction

        public FileChooserAction​(java.util.Observable observable,
                                 java.lang.String caption,
                                 javax.swing.filechooser.FileFilter filter,
                                 boolean newFile)
        Creates a new file chooser action.
        Parameters:
        observable - the object waiting for you to select file
        caption - a description for the action
        filter - a filter to apply when browsing
        newFile - indicates if you should browse for a new or existing file
    • Method Detail

      • getFile

        public java.io.File getFile()
        Getter for the file.
        Returns:
        a file
      • actionPerformed

        public void actionPerformed​(java.awt.event.ActionEvent evt)
        See Also:
        ActionListener.actionPerformed(java.awt.event.ActionEvent)