Java JFrame Show open(JFrame view)

Here you can find the source of open(JFrame view)

Description

Creates "Open file" dialog.

License

Open Source License

Parameter

Parameter Description
view parent view.

Return

chosen file.

Declaration

public static File open(JFrame view) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import javax.swing.*;
import java.io.File;

public class Main {
    private static JFileChooser chooser = new JFileChooser();
    private static File file;

    /**/* www.j ava2  s  . co m*/
     * Creates "Open file" dialog.
     *
     * @param view parent view.
     * @return chosen file.
     */
    public static File open(JFrame view) {
        int fileChosen = chooser.showDialog(view, "Open file");
        if (fileChosen == JFileChooser.APPROVE_OPTION) {
            chooser.requestFocus();
            file = chooser.getSelectedFile();
        }
        return file;
    }
}

Related

  1. isShowing(JFrame f)
  2. show(JFrame frame)
  3. showAndSaveReportFile(JFrame frmParent, File defaultReportFile, String data)
  4. showDemoFrame(JFrame frame)
  5. showFrame(JFrame frame)