Class FileOpenSaveDialog

java.lang.Object
hipp.com.wappedidpadpro2.FileOpenSaveDialog

public class FileOpenSaveDialog
extends java.lang.Object
FileOpenSaveDialog
javax.swing.JFileChooser
  • Field Summary

    Fields 
    Modifier and Type Field Description
    private static javax.swing.JFileChooser fileChooser  
    private java.awt.Component mainUI  
  • Constructor Summary

    Constructors 
    Constructor Description
    FileOpenSaveDialog​(java.awt.Component parentUI, ExtensionFileFilter fileFilter)
    Constructor.
  • Method Summary

    Modifier and Type Method Description
    java.io.File openFile()
    open a file prompting user to select the file.
    boolean saveFile​(byte[] bytes, java.lang.String extension)
    Saves data into a file after the user is prompted to choose the destination.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • fileChooser

      private static final javax.swing.JFileChooser fileChooser
    • mainUI

      private final java.awt.Component mainUI
  • Constructor Details

    • FileOpenSaveDialog

      public FileOpenSaveDialog​(java.awt.Component parentUI, ExtensionFileFilter fileFilter)
      Constructor.
      Parameters:
      parentUI - the main UI (JFrame) on top of which File open/save dialog should open.
      fileFilter - file Filter, null is allowed when no filter is applicable.
  • Method Details

    • saveFile

      public boolean saveFile​(byte[] bytes, java.lang.String extension) throws java.io.IOException
      Saves data into a file after the user is prompted to choose the destination.
      Parameters:
      bytes - byte array to be saved in a file.
      extension - file extension.
      Returns:
      true if the file is saved successfully or false if failed.
      Throws:
      java.io.IOException - if there is an error in creation of the file.
    • openFile

      public java.io.File openFile() throws java.io.IOException
      open a file prompting user to select the file.
      Returns:
      the file opened.
      Throws:
      java.io.IOException - if there is error in opening the file.