/* This program demonstrates some standard pop-up Java dialogs. Author: Charlie McDowell */ import javax.swing.*; class DialogSampler { public static void main(String[] args) { System.out.println("hello"); // just so we know the program has started // pop-up a file chooser that let's you select a file JFileChooser choose = new JFileChooser(); // if using a gui replace the null with the JFrame or other // component that this dialog should be bound to choose.showOpenDialog(null); String fileName = choose.getSelectedFile().getName(); System.out.println(fileName); // Input some string in a dialog box. String input = JOptionPane.showInputDialog("Type something"); System.out.println(input); // Confirm with Yes/No/Cancel (integers 0/1/2) int response = JOptionPane.showConfirmDialog(null, "Really?"); System.out.println("response is " + response); JOptionPane.showMessageDialog(null, "That's all folks!"); System.exit(0); //needed because dialogs spun off an awt thread } }