56 import javax.accessibility.*; 57 import static javax.swing.ClientPropertyKey.PopupFactory_FORCE_HEAVYWEIGHT_POPUP; 58 import sun.awt.AWTAccessor; 59 60 /** 61 * <code>JOptionPane</code> makes it easy to pop up a standard dialog box that 62 * prompts users for a value or informs them of something. 63 * For information about using <code>JOptionPane</code>, see 64 * <a 65 href="http://docs.oracle.com/javase/tutorial/uiswing/components/dialog.html">How to Make Dialogs</a>, 66 * a section in <em>The Java Tutorial</em>. 67 * 68 * <p> 69 * 70 * While the <code>JOptionPane</code> 71 * class may appear complex because of the large number of methods, almost 72 * all uses of this class are one-line calls to one of the static 73 * <code>showXxxDialog</code> methods shown below: 74 * <blockquote> 75 * 76 * 77 * <table border=1 summary="Common JOptionPane method names and their descriptions"> 78 * <tr> 79 * <th>Method Name</th> 80 * <th>Description</th> 81 * </tr> 82 * <tr> 83 * <td>showConfirmDialog</td> 84 * <td>Asks a confirming question, like yes/no/cancel.</td> 85 * </tr> 86 * <tr> 87 * <td>showInputDialog</td> 88 * <td>Prompt for some input.</td> 89 * </tr> 90 * <tr> 91 * <td>showMessageDialog</td> 92 * <td>Tell the user about something that has happened.</td> 93 * </tr> 94 * <tr> 95 * <td>showOptionDialog</td> 96 * <td>The Grand Unification of the above three.</td> 97 * </tr> 98 * </table> 99 * 100 * </blockquote> 101 * Each of these methods also comes in a <code>showInternalXXX</code> 102 * flavor, which uses an internal frame to hold the dialog box (see 103 * {@link JInternalFrame}). 104 * Multiple convenience methods have also been defined -- overloaded 105 * versions of the basic methods that use different parameter lists. 106 * <p> 107 * All dialogs are modal. Each <code>showXxxDialog</code> method blocks 108 * the caller until the user's interaction is complete. 109 * 110 * <table cellspacing=6 cellpadding=4 border=0 style="float:right" summary="layout"> 111 * <tr> 112 * <td style="background-color:#FFe0d0" rowspan=2>icon</td> 113 * <td style="background-color:#FFe0d0">message</td> 114 * </tr> 115 * <tr> 116 * <td style="background-color:#FFe0d0">input value</td> 117 * </tr> 118 * <tr> 119 * <td style="background-color:#FFe0d0" colspan=2>option buttons</td> 120 * </tr> 121 * </table> 122 * 123 * The basic appearance of one of these dialog boxes is generally 124 * similar to the picture at the right, although the various 125 * look-and-feels are 126 * ultimately responsible for the final result. In particular, the 127 * look-and-feels will adjust the layout to accommodate the option pane's 128 * <code>ComponentOrientation</code> property. 129 * <br style="clear:all"> 130 * <p> 131 * <b>Parameters:</b><br> 132 * The parameters to these methods follow consistent patterns: 133 * <blockquote> 134 * <dl> 135 * <dt>parentComponent<dd> 136 * Defines the <code>Component</code> that is to be the parent of this 137 * dialog box. 138 * It is used in two ways: the <code>Frame</code> that contains 139 * it is used as the <code>Frame</code> 140 * parent for the dialog box, and its screen coordinates are used in 141 * the placement of the dialog box. In general, the dialog box is placed 142 * just below the component. This parameter may be <code>null</code>, 143 * in which case a default <code>Frame</code> is used as the parent, 144 * and the dialog will be | 56 import javax.accessibility.*; 57 import static javax.swing.ClientPropertyKey.PopupFactory_FORCE_HEAVYWEIGHT_POPUP; 58 import sun.awt.AWTAccessor; 59 60 /** 61 * <code>JOptionPane</code> makes it easy to pop up a standard dialog box that 62 * prompts users for a value or informs them of something. 63 * For information about using <code>JOptionPane</code>, see 64 * <a 65 href="http://docs.oracle.com/javase/tutorial/uiswing/components/dialog.html">How to Make Dialogs</a>, 66 * a section in <em>The Java Tutorial</em>. 67 * 68 * <p> 69 * 70 * While the <code>JOptionPane</code> 71 * class may appear complex because of the large number of methods, almost 72 * all uses of this class are one-line calls to one of the static 73 * <code>showXxxDialog</code> methods shown below: 74 * <blockquote> 75 * 76 * <table class="striped"> 77 * <caption style="display:none">Common JOptionPane method names and their 78 * descriptions</caption> 79 * <thead> 80 * <tr> 81 * <th>Method Name</th> 82 * <th>Description</th> 83 * </tr> 84 * </thead> 85 * <tbody> 86 * <tr> 87 * <td>showConfirmDialog</td> 88 * <td>Asks a confirming question, like yes/no/cancel.</td> 89 * </tr> 90 * <tr> 91 * <td>showInputDialog</td> 92 * <td>Prompt for some input.</td> 93 * </tr> 94 * <tr> 95 * <td>showMessageDialog</td> 96 * <td>Tell the user about something that has happened.</td> 97 * </tr> 98 * <tr> 99 * <td>showOptionDialog</td> 100 * <td>The Grand Unification of the above three.</td> 101 * </tr> 102 * </tbody> 103 * </table> 104 * 105 * </blockquote> 106 * Each of these methods also comes in a <code>showInternalXXX</code> 107 * flavor, which uses an internal frame to hold the dialog box (see 108 * {@link JInternalFrame}). 109 * Multiple convenience methods have also been defined -- overloaded 110 * versions of the basic methods that use different parameter lists. 111 * <p> 112 * All dialogs are modal. Each <code>showXxxDialog</code> method blocks 113 * the caller until the user's interaction is complete. 114 * 115 * <table class="borderless"> 116 * <caption style="display:none">Common dialog</caption> 117 * <tr> 118 * <td style="background-color:#FFe0d0" rowspan=2>icon</td> 119 * <td style="background-color:#FFe0d0">message</td> 120 * </tr> 121 * <tr> 122 * <td style="background-color:#FFe0d0">input value</td> 123 * </tr> 124 * <tr> 125 * <td style="background-color:#FFe0d0" colspan=2>option buttons</td> 126 * </tr> 127 * </table> 128 * 129 * The basic appearance of one of these dialog boxes is generally 130 * similar to the picture above, although the various 131 * look-and-feels are 132 * ultimately responsible for the final result. In particular, the 133 * look-and-feels will adjust the layout to accommodate the option pane's 134 * <code>ComponentOrientation</code> property. 135 * <br style="clear:all"> 136 * <p> 137 * <b>Parameters:</b><br> 138 * The parameters to these methods follow consistent patterns: 139 * <blockquote> 140 * <dl> 141 * <dt>parentComponent<dd> 142 * Defines the <code>Component</code> that is to be the parent of this 143 * dialog box. 144 * It is used in two ways: the <code>Frame</code> that contains 145 * it is used as the <code>Frame</code> 146 * parent for the dialog box, and its screen coordinates are used in 147 * the placement of the dialog box. In general, the dialog box is placed 148 * just below the component. This parameter may be <code>null</code>, 149 * in which case a default <code>Frame</code> is used as the parent, 150 * and the dialog will be |