Here you can find the source of getFileChooser()
public static JFileChooser getFileChooser()
//package com.java2s; //License from project: Open Source License import java.awt.Window; import javax.swing.JDialog; import javax.swing.JFileChooser; public class Main { public static JFileChooser getFileChooser() { for (Window w : Window.getWindows()) if (w instanceof JDialog && w.isShowing()) if (((JDialog) w).getContentPane().getComponent(0) instanceof JFileChooser) return (JFileChooser) ((JDialog) w).getContentPane().getComponent(0); throw new IllegalStateException("no file chooser found!"); }/*from ww w. j ava2 s. co m*/ }