Check out example codes for "java filedialog". It will help you in understanding the concepts better.

Code Example 1

FileDialog fd = new FileDialog(yourJFrame, "Choose a file", FileDialog.LOAD);
fd.setDirectory("C:\\");
fd.setFile("*.xml");
fd.setVisible(true);
String filename = fd.getFile();
if (filename == null)
    System.out.println("You cancelled the choice");
else
    System.out.println("You chose " + filename);

Learn ReactJs, React Native from akashmittal.com