FileDocCategorySizeDatePackage
FileDialogDemo.javaAPI DocExample1103Sat Nov 25 12:55:12 GMT 2000None

FileDialogDemo

public class FileDialogDemo extends Frame

Fields Summary
FileDialog
fc
Constructors Summary
FileDialogDemo()
Construct a FileDialogDemo

		super("FileDialogDemo");
		setSize(200, 200);

		// Construct, but don't show, the file dialog.
		fc = new FileDialog(this, "Choose a file", FileDialog.LOAD);
		// Set its starting directory to the root, not where we run it
		// (just to show that there are some methods you can call on it).
		fc.setDirectory("C:\\");

		Button b;
		add(b = new Button("Browse..."));	// Create and add a Button
		b.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				// Make the dialog appear, and wait for it.
				fc.setVisible(true);
				// If we get here, user either chose a file or did CANCEL.
				String fn = fc.getFile();
				if (fn == null)
					System.out.println("You cancelled the choice");
				else
					System.out.println("You chose " + fn);
			}
		});
	
Methods Summary
public static voidmain(java.lang.String[] a)
main test program: construct the Frame and show it

		new FileDialogDemo().setVisible(true);