Java AWT FileDialog create
import java.awt.Button; import java.awt.FileDialog; import java.awt.FlowLayout; import java.awt.TextField; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JFrame; public class Main extends JFrame { FileDialog fd;//from w ww . j av a2 s. co m TextField t = new TextField(20); Main() { setSize(300, 150); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setLayout(new FlowLayout()); Button b = new Button("Select a file"); add(b); add(t); b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { fd.setVisible(true); t.setText(fd.getFile()); } }); setVisible(true); fd = new FileDialog(this); } public static void main(String args[]) { new Main(); } }