Java Reference
In-Depth Information
As another example, the right dialog window in Fig. 17.8 was created with
fourth argument JOptionPane.INFORMATION_MESSAGE .
Modal windows
These dialog windows are modal dialog windows. This means that, when
they are shown, they capture the focus, and clicking on other windows belong-
ing to this execution will have no effect. You must close this window before any-
thing else can happen in the program.
The first argument, the parent
The first argument in calls to showMessageDialog is called the parent win-
dow of the dialog window. If the first argument is null , the dialog window
appears in the center of the monitor. However, suppose the first argument is the
name window (say) of some window that is already showing on the monitor.
Then, when the dialog window is created and shown, it is shown in front of win-
dow window .
Function showInputDialog
String function JOptionPane.showInputDialog displays a modal dialog
window with a message and returns text typed by the user. An example window
appears to the left in Fig. 17.19. A call has four parameters:
1. The parent (as with method showMessageDialog ).
2. The message (a String ). In the example, it is "What's your opinion
about eating meat?" .
3. The title (a String ). In the example, it is: "question message" .
4. The style of the window, which tells what picture to put in the window. It
is one of the following constants of JOptionPane :
Figure 17.20:
A showOptionDialog window
Search WWH ::

Custom Search