JFileChooser chooser = new JFileChooser();

// Show the dialog; wait until dialog is closed
int result = chooser.showOpenDialog(frame);

// Determine which button was clicked to close the dialog
switch (result) {
  case JFileChooser.APPROVE_OPTION:
    // Approve (Open or Save) was clicked
  case JFileChooser.CANCEL_OPTION:
    // Cancel or the close-dialog icon was clicked
  case JFileChooser.ERROR_OPTION:
    // The selection process did not complete successfully

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.