Dialog Boxes, Pop-Ups, and Choosers


As mentioned earlier, dialog boxes are single-purpose windows for functions such as login and yes/no screens. You can construct your own dialog box with a JDialog component or use one of the Swing components , including JOptionPane, JFileChooser, and JColorChooser. For the assignment, you could use a dialog box as a prompt for how many reservations are needed, if that is part of the functionality your instructions require. The following snippets are examples of using dialog boxes:

 // Modal OK dialog JFrame myFrame = new JFrame("my new frame"); JOptionPane.showMessageDialog(myFrame, "SCJD or bust"); //File dialog File file = new File(File.separator + "bin"); JFileChooser fileDialog = new JFileChooser(file); fileDialog.showSaveDialog(myFrame); File myFile = fileDialog.getSelectedFile(); 


JavaT 2 Developer Exam CramT 2 (Exam CX-310-252A and CX-310-027)
JavaT 2 Developer Exam CramT 2 (Exam CX-310-252A and CX-310-027)
ISBN: N/A
EAN: N/A
Year: 2003
Pages: 187

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net