Displaying Text in a Dialog Box
The programs presented thus far display output in the command window. Many applications
use windows or dialog boxes (also called dialogs) to display output. Web browsers
such as Firefox, Internet Explorer, Chrome and Safari display web pages in their own windows.
E-mail programs allow you to type and read messages in a window. Typically, dialog
boxes are windows in which programs display important messages to users. Class JOption-Pane provides prebuilt dialog boxes that enable programs to display windows containing
messages—such windows are called message dialogs.
Introducing static Methods
JOptionPane method showMessageDialog is a so-called static method. Such methods
often define frequently used tasks. For example, many programs display dialog boxes, and
the code to do this is the same each time. Rather than requiring you to “reinvent the
wheel” and create code to display a dialog, the designers of class JOptionPane declared a
static method that performs this task for you. A static method is called by using its class
name followed by a dot (.) and the method name, as in
ClassName.methodName( arguments )
I like the illustrations as it shows how easy that part is to do . Great class !!!
ReplyDelete