Java Reference
In-Depth Information
Table 9-2. JOptionPane Static create and show Methods
Method Name/Return Type
Parent
Component
Component
Message
Object
Title
String
Option
Type int
Message
Type int
showMessageDialog
Return type: void [123]
123
123
23
23
showInternalMessageDialog
Return type: void [123]
123
123
23
23
showConfirmDialog
Return type: int [1234]
1234
1234
234
234
34
showInternalConfirmDialog
Return type: int
1234
1234
234
234
34
showInputDialog
Return type: String [12356]/ Object [4]
2345
123456
34
34
showInternalInputDialog
Return type: String [12]/ Object [3]
123
123
23
23
showOptionDialog
Return type: int [1]
1
1
1
1
1
showInternalOptionDialog
Return type: int [1]
1
1
1
1
1
JOptionPane Arguments for Factory Methods
Almost all the arguments for the factory methods match the JOptionPane constructor arguments.
Two lists in the “Creating a JOptionPane” section earlier in this chapter describe the acceptable
values for the message type and option type arguments. In addition, the usage of the message,
options, and initial value arguments are also described. The parent component and title
argument are passed along to one of the createDialog() or createInternalFrame() methods,
depending on the type of pop-up in which the JOptionPane is embedded.
You next need to consider the selection values argument and the initial selection value
argument of the showInputDialog() method. With an input dialog box, you can ask the user for
text input and allow the user to type in anything, or you can present the user with a list of
predefined choices. The selection values argument to showInputDialog() determines how you
provide that set of choices. The initial selection value represents the specific option to be chosen
when the JOptionPane first appears. The look and feel will determine the appropriate Swing
component to be used based on the number of choices presented. For small lists, a JComboBox
is used. For larger lists, starting at 20 with the Motif, Metal/Ocean, and Windows look and feel
types, a JList is used.
Search WWH ::




Custom Search