import java.awt.*; public class DisplayFileDialog { public static void main(String[] args) { // no need to handle window-closing operations // because the frame is not visible, only the dialog Frame f = new Frame(); FileDialog d = new FileDialog(f, "Open"); d.setVisible(true); String selectedItem = d.getFile(); if (selectedItem == null) selectedItem = "No file selection."; System.out.println("You selected: " + selectedItem); f.dispose(); System.exit(0); } }