Class JFileImageChooser

  • All Implemented Interfaces:
    ImageObserver, MenuContainer, Serializable, Accessible

    public class JFileImageChooser
    extends JFileChooser
    A file chooser dialog for common raster image format files. It provides static methods to display the dialog for opening or saving an image file. The file formats offered by the dialog are a subset of those supported by ImageIO on the host system.
    
     // Prompting for an input image file
     File file = JFileImageChooser.showOpenFile();
     if (file != null) {
         ...
     }
    
     // Prompting for a file name to save an image
     File file = JFileImageChooser.showSaveFile();
     if (file != null) {
         ...
     }
     
    Since:
    2.6.1
    Author:
    Michael Bedward
    See Also:
    Serialized Form
    • Method Detail

      • showSaveFile

        public static File showSaveFile()
        Prompts for file name to save an image.
        Returns:
        the selected file or null if the dialog was cancelled
      • showSaveFile

        public static File showSaveFile​(Component parent)
        Prompts for file name to save an image.
        Parameters:
        parent - parent component (may be null)
        Returns:
        the selected file or null if the dialog was cancelled
      • showSaveFile

        public static File showSaveFile​(Component parent,
                                        File workingDir)
        Prompts for file name to save an image.
        Parameters:
        parent - parent component (may be null)
        workingDir - the initial directory
        Returns:
        the selected file or null if the dialog was cancelled
      • showOpenFile

        public static File showOpenFile()
        Prompts for file name to read an image.
        Returns:
        the selected file or null if the dialog was cancelled
      • showOpenFile

        public static File showOpenFile​(Component parent)
        Prompts for file name to read an image.
        Parameters:
        parent - parent component (may be null)
        Returns:
        the selected file or null if the dialog was cancelled
      • showOpenFile

        public static File showOpenFile​(Component parent,
                                        File workingDir)
        Prompts for file name to read an image.
        Parameters:
        parent - parent component (may be null)
        workingDir - the initial directory
        Returns:
        the selected file or null if the dialog was cancelled