< prev index next >

src/java.desktop/share/classes/javax/swing/JOptionPane.java

Print this page




  54 import javax.swing.event.InternalFrameEvent;
  55 import javax.swing.event.InternalFrameAdapter;
  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>Common JOptionPane method names and their descriptions</caption>
  78  * <thead>
  79  * <tr>
  80  *    <th>Method Name</th>
  81  *    <th>Description</th>
  82  * </tr>
  83  * </thead>
  84  * <tbody>
  85  * <tr>
  86  *    <td>showConfirmDialog</td>
  87  *    <td>Asks a confirming question, like yes/no/cancel.</td>
  88  * </tr>
  89  * <tr>
  90  *    <td>showInputDialog</td>
  91  *    <td>Prompt for some input.</td>
  92  * </tr>
  93  * <tr>
  94  *   <td>showMessageDialog</td>
  95  *   <td>Tell the user about something that has happened.</td>
  96  * </tr>
  97  * <tr>
  98  *   <td>showOptionDialog</td>
  99  *   <td>The Grand Unification of the above three.</td>
 100  * </tr>
 101  * </tbody>
 102  * </table>
 103  *
 104  * </blockquote>
 105  * Each of these methods also comes in a <code>showInternalXXX</code>
 106  * flavor, which uses an internal frame to hold the dialog box (see
 107  * {@link JInternalFrame}).
 108  * Multiple convenience methods have also been defined -- overloaded
 109  * versions of the basic methods that use different parameter lists.
 110  * <p>
 111  * All dialogs are modal. Each <code>showXxxDialog</code> method blocks
 112  * the caller until the user's interaction is complete.
 113  *
 114  * <table class="borderless">
 115  * <caption>Common dialog</caption>
 116  * <tr>
 117  *  <td style="background-color:#FFe0d0" rowspan=2>icon</td>
 118  *  <td style="background-color:#FFe0d0">message</td>
 119  * </tr>
 120  * <tr>
 121  *  <td style="background-color:#FFe0d0">input value</td>
 122  * </tr>
 123  * <tr>
 124  *   <td style="background-color:#FFe0d0" colspan=2>option buttons</td>




  54 import javax.swing.event.InternalFrameEvent;
  55 import javax.swing.event.InternalFrameAdapter;
  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  *
  75  * <table class="striped">
  76  * <caption>Common JOptionPane method names and their descriptions</caption>
  77  * <thead>
  78  *   <tr>
  79  *     <th scope="col">Method Name
  80  *     <th scope="col">Description

  81  * </thead>
  82  * <tbody>
  83  *   <tr>
  84  *     <th scope="row">showConfirmDialog
  85  *     <td>Asks a confirming question, like yes/no/cancel.</td>

  86  *   <tr>
  87  *     <th scope="row">showInputDialog
  88  *     <td>Prompt for some input.

  89  *   <tr>
  90  *     <th scope="row">showMessageDialog
  91  *     <td>Tell the user about something that has happened.

  92  *   <tr>
  93  *     <th scope="row">showOptionDialog
  94  *     <td>The Grand Unification of the above three.

  95  * </tbody>
  96  * </table>
  97  *

  98  * Each of these methods also comes in a <code>showInternalXXX</code>
  99  * flavor, which uses an internal frame to hold the dialog box (see
 100  * {@link JInternalFrame}).
 101  * Multiple convenience methods have also been defined -- overloaded
 102  * versions of the basic methods that use different parameter lists.
 103  * <p>
 104  * All dialogs are modal. Each <code>showXxxDialog</code> method blocks
 105  * the caller until the user's interaction is complete.
 106  *
 107  * <table class="borderless">
 108  * <caption>Common dialog</caption>
 109  * <tr>
 110  *  <td style="background-color:#FFe0d0" rowspan=2>icon</td>
 111  *  <td style="background-color:#FFe0d0">message</td>
 112  * </tr>
 113  * <tr>
 114  *  <td style="background-color:#FFe0d0">input value</td>
 115  * </tr>
 116  * <tr>
 117  *   <td style="background-color:#FFe0d0" colspan=2>option buttons</td>


< prev index next >