|
Java example source code file (JOptionPane.java)
The JOptionPane.java Java example source code/* * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package javax.swing; import java.awt.BorderLayout; import java.awt.Component; import java.awt.Container; import java.awt.Dialog; import java.awt.Dimension; import java.awt.KeyboardFocusManager; import java.awt.Frame; import java.awt.Point; import java.awt.HeadlessException; import java.awt.Window; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.awt.event.WindowListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.awt.event.ComponentAdapter; import java.awt.event.ComponentEvent; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.lang.reflect.Method; import java.lang.reflect.InvocationTargetException; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.Vector; import javax.swing.plaf.OptionPaneUI; import javax.swing.event.InternalFrameEvent; import javax.swing.event.InternalFrameAdapter; import javax.accessibility.*; import static javax.swing.ClientPropertyKey.PopupFactory_FORCE_HEAVYWEIGHT_POPUP; /** * <code>JOptionPane makes it easy to pop up a standard dialog box that * prompts users for a value or informs them of something. * For information about using <code>JOptionPane, see * <a href="http://docs.oracle.com/javase/tutorial/uiswing/components/dialog.html">How to Make Dialogs</a>, * a section in <em>The Java Tutorial. * * <p> * * While the <code>JOptionPane * class may appear complex because of the large number of methods, almost * all uses of this class are one-line calls to one of the static * <code>showXxxDialog methods shown below: * <blockquote> * * * <table border=1 summary="Common JOptionPane method names and their descriptions"> * <tr> * <th>Method Name * <th>Description * </tr> * <tr> * <td>showConfirmDialog |
* <td>Asks a confirming question, like yes/no/cancel.
* </tr>
* <tr>
* <td>showInputDialog
* <td>Prompt for some input.
* </tr>
* <tr>
* <td>showMessageDialog
* <td>Tell the user about something that has happened.
* </tr>
* <tr>
* <td>showOptionDialog
* <td>The Grand Unification of the above three.
* </tr>
* </table>
*
* </blockquote>
* Each of these methods also comes in a <code>showInternalXXX
* flavor, which uses an internal frame to hold the dialog box (see
* {@link JInternalFrame}).
* Multiple convenience methods have also been defined -- overloaded
* versions of the basic methods that use different parameter lists.
* <p>
* All dialogs are modal. Each <code>showXxxDialog method blocks
* the caller until the user's interaction is complete.
*
* <table cellspacing=6 cellpadding=4 border=0 style="float:right" summary="layout">
* <tr>
* <td style="background-color:#FFe0d0" rowspan=2>icon
* <td style="background-color:#FFe0d0">message
* </tr>
* <tr>
* <td style="background-color:#FFe0d0">input value
* </tr>
* <tr>
* <td style="background-color:#FFe0d0" colspan=2>option buttons
* </tr>
* </table>
*
* The basic appearance of one of these dialog boxes is generally
* similar to the picture at the right, although the various
* look-and-feels are
* ultimately responsible for the final result. In particular, the
* look-and-feels will adjust the layout to accommodate the option pane's
* <code>ComponentOrientation property.
* <br style="clear:all">
* <p>
* <b>Parameters:
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.