Java tutorial
import java.io.File; import javax.swing.JButton; import javax.swing.JFileChooser; import javax.swing.JFrame; import javax.swing.JPanel; public class Main { public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel panel = new JPanel(); final JButton button = new JButton("Select files..."); button.addActionListener(e -> { final JFileChooser chooser = new JFileChooser(); chooser.setCurrentDirectory(chooser.getFileSystemView().getParentDirectory(new File("C:\\"))); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.showDialog(button, "Select file"); }); panel.add(button); frame.add(panel); frame.pack(); frame.setVisible(true); } }