Java JFrame Parent fileOpen(Frame parent, String typename, String ext)

Here you can find the source of fileOpen(Frame parent, String typename, String ext)

Description

file Open

License

Open Source License

Declaration

public static File fileOpen(Frame parent, String typename, String ext) 

Method Source Code

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

import java.awt.Frame;

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

import javax.swing.filechooser.FileNameExtensionFilter;

public class Main {
    static String lastpathload = null;

    public static File fileOpen(Frame parent, String typename, String ext) {
        JFileChooser chooser = new JFileChooser();
        FileNameExtensionFilter filter = new FileNameExtensionFilter(typename, ext);
        chooser.setFileFilter(filter);//  www . j  av  a2  s  . com
        chooser.setCurrentDirectory(lastpathload != null ? new File(lastpathload) : null);
        int returnVal = chooser.showOpenDialog(parent);
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            lastpathload = chooser.getSelectedFile().getPath();
            return chooser.getSelectedFile();
        }
        return null;

    }
}

Related

  1. createProgressDialog(Frame parentFrame, String title, JProgressBar progressBar)
  2. enableAllComponents(final boolean enable, final Frame parent)
  3. enableAllComponentsExcept(final boolean enable, final Frame parent, final Component... components)
  4. ensureVisibilityAtParent(final JInternalFrame frame)
  5. execLoop(JComponent editor, Frame parent, boolean modal, int w, int h)
  6. findParentDialogOrFrame(Container container)
  7. getFirstParentFrameOrDialog(Component cmp)
  8. getFrame(Component parent)
  9. getFrameParent(Component component)