Friday 1 September 2017

Java Dialog Box

Cited from the Book Java How to Program

Class JOptionPane from package javax.swing provides prebuilt dialog boxes that enable programs to display windows containing messages -- such windows are called message dialogs.

The method showMessageDialog of the JOptionPane class displays a dialog box containing a message. The method requires two arguments. The first helps the Java application determine where to position the dialog box. A dialog is typically displayed from a GUI application with its own window. The first argument refers to that window (known as the parent window) and causes the dialog to appear centered over the application’s window. If the first argument is null, the dialog box is displayed at the center of your screen. The second argument is the String to display in the dialog box.

The method showInputDialog of the JOptionPane class displays an input dialog containing a prompt and a field (known as a text field) in which the user can enter text. If you press the dialog’s Cancel button or press the Esc key, the method returns null and the program displays the word “null” as the name.


No comments:

Post a Comment