⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 joptionpane.java

📁 gcc的组建
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
/* JOptionPane.java   Copyright (C) 2004, 2005 Free Software Foundation, Inc.This file is part of GNU Classpath.GNU Classpath is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2, or (at your option)any later version.GNU Classpath is distributed in the hope that it will be useful, butWITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNUGeneral Public License for more details.You should have received a copy of the GNU General Public Licensealong with GNU Classpath; see the file COPYING.  If not, write to theFree Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA02110-1301 USA.Linking this library statically or dynamically with other modules ismaking a combined work based on this library.  Thus, the terms andconditions of the GNU General Public License cover the wholecombination.As a special exception, the copyright holders of this library give youpermission to link this library with independent modules to produce anexecutable, regardless of the license terms of these independentmodules, and to copy and distribute the resulting executable underterms of your choice, provided that you also meet, for each linkedindependent module, the terms and conditions of the license of thatmodule.  An independent module is a module which is not derived fromor based on this library.  If you modify this library, you may extendthis exception to your version of the library, but you are notobligated to do so.  If you do not wish to do so, delete thisexception statement from your version. */package javax.swing;import java.awt.Component;import java.awt.Frame;import javax.accessibility.Accessible;import javax.accessibility.AccessibleContext;import javax.accessibility.AccessibleRole;import javax.swing.event.InternalFrameAdapter;import javax.swing.event.InternalFrameEvent;import javax.swing.plaf.OptionPaneUI;/** * This class creates different types of JDialogs and JInternalFrames that can * ask users for input or pass on information. JOptionPane can be used by * calling one of the show static methods or  by creating an instance of * JOptionPane and calling createDialog or createInternalFrame. */public class JOptionPane extends JComponent implements Accessible{  /**   * DOCUMENT ME!   */  // FIXME: This inner class is a complete stub and needs to be implemented  // properly.  protected class AccessibleJOptionPane extends JComponent.AccessibleJComponent  {    /** DOCUMENT ME! */    private static final long serialVersionUID = 686071432213084821L;        /**     * Creates a new AccessibleJOptionPane object.     */    protected AccessibleJOptionPane()    {      // Nothing to do here.    }    /**     * DOCUMENT ME!     *     * @return DOCUMENT ME!     */    public AccessibleRole getAccessibleRole()    {      return null;    }  }  /** DOCUMENT ME! */  private static final long serialVersionUID = 5231143276678566796L;  /** The value returned when cancel option is selected. */  public static final int CANCEL_OPTION = 2;  /** The value returned when the dialog is closed without a selection. */  public static final int CLOSED_OPTION = -1;  /** An option used in confirmation dialog methods. */  public static final int DEFAULT_OPTION = -1;  /** The value returned when the no option is selected. */  public static final int NO_OPTION = 1;  /** An option used in confirmation dialog methods. */  public static final int OK_CANCEL_OPTION = 2;  /** The value returned when the ok option is selected. */  public static final int OK_OPTION = 0;  /** An option used in confirmation dialog methods. */  public static final int YES_NO_CANCEL_OPTION = 1;  /** An option used in confirmation dialog methods. */  public static final int YES_NO_OPTION = 0;  /** The value returned when the yes option is selected. */  public static final int YES_OPTION = 0;  /** Identifier for the error message type. */  public static final int ERROR_MESSAGE = 0;  /** Identifier for the information message type. */  public static final int INFORMATION_MESSAGE = 1;  /** Identifier for the plain message type. */  public static final int PLAIN_MESSAGE = -1;  /** Identifier for the question message type. */  public static final int QUESTION_MESSAGE = 3;  /** Identifier for the warning message type. */  public static final int WARNING_MESSAGE = 2;  /**   * The identifier for the propertyChangeEvent when the icon property   * changes.   */  public static final String ICON_PROPERTY = "icon";  /**   * The identifier for the propertyChangeEvent when the initialSelectionValue   * property changes.   */  public static final String INITIAL_SELECTION_VALUE_PROPERTY = "initialSelectionValue";  /**   * The identifier for the propertyChangeEvent when the initialValue property   * changes.   */  public static final String INITIAL_VALUE_PROPERTY = "initialValue";  /**   * The identifier for the propertyChangeEvent when the inputValue property   * changes.   */  public static final String INPUT_VALUE_PROPERTY = "inputValue";  /**   * The identifier for the propertyChangeEvent when the message property   * changes.   */  public static final String MESSAGE_PROPERTY = "message";  /**   * The identifier for the propertyChangeEvent when the messageType property   * changes.   */  public static final String MESSAGE_TYPE_PROPERTY = "messageType";  /**   * The identifier for the propertyChangeEvent when the optionType property   * changes.   */  public static final String OPTION_TYPE_PROPERTY = "optionType";  /**   * The identifier for the propertyChangeEvent when the options property   * changes.   */  public static final String OPTIONS_PROPERTY = "options";  /**   * The identifier for the propertyChangeEvent when the selectionValues   * property changes.   */  public static final String SELECTION_VALUES_PROPERTY = "selectionValues";  /**   * The identifier for the propertyChangeEvent when the value property   * changes.   */  public static final String VALUE_PROPERTY = "value";  /**   * The identifier for the propertyChangeEvent when the wantsInput property   * changes.   */  public static final String WANTS_INPUT_PROPERTY = "wantsInput";  /** The value returned when the inputValue is uninitialized. */  public static Object UNINITIALIZED_VALUE = "uninitializedValue";  /** The icon displayed in the dialog/internal frame. */  protected Icon icon;  /** The initial selected value in the input component. */  protected Object initialSelectionValue;  /** The object that is initially selected for options. */  protected Object initialValue;  /** The value the user inputs. */  protected Object inputValue = UNINITIALIZED_VALUE;  /** The message displayed in the dialog/internal frame. */  protected Object message;  /** The type of message displayed. */  protected int messageType = PLAIN_MESSAGE;  /**   * The options (usually buttons) aligned at the bottom for the user to   * select.   */  protected Object[] options;  /** The type of options to display. */  protected int optionType = DEFAULT_OPTION;  /** The input values the user can select. */  protected Object[] selectionValues;  /** The value returned by selecting an option. */  protected Object value = UNINITIALIZED_VALUE;  /** Whether the Dialog/InternalFrame needs input. */  protected boolean wantsInput;  /** The common frame used when no parent is provided. */  private static Frame privFrame = SwingUtilities.getOwnerFrame();  /**   * Creates a new JOptionPane object using a message of "JOptionPane   * message", using the PLAIN_MESSAGE type and DEFAULT_OPTION.   */  public JOptionPane()  {    this("JOptionPane message", PLAIN_MESSAGE, DEFAULT_OPTION, null, null, null);  }  /**   * Creates a new JOptionPane object using the given message using the   * PLAIN_MESSAGE type and DEFAULT_OPTION.   *   * @param message The message to display.   */  public JOptionPane(Object message)  {    this(message, PLAIN_MESSAGE, DEFAULT_OPTION, null, null, null);  }  /**   * Creates a new JOptionPane object using the given message and messageType   * and DEFAULT_OPTION.   *   * @param message The message to display.   * @param messageType The type of message.   */  public JOptionPane(Object message, int messageType)  {    this(message, messageType, DEFAULT_OPTION, null, null, null);  }  /**   * Creates a new JOptionPane object using the given message, messageType and   * optionType.   *   * @param message The message to display.   * @param messageType The type of message.   * @param optionType The type of options.   */  public JOptionPane(Object message, int messageType, int optionType)  {    this(message, messageType, optionType, null, null, null);  }  /**   * Creates a new JOptionPane object using the given message, messageType,   * optionType and icon.   *   * @param message The message to display.   * @param messageType The type of message.   * @param optionType The type of options.   * @param icon The icon to display.   */  public JOptionPane(Object message, int messageType, int optionType, Icon icon)  {    this(message, messageType, optionType, icon, null, null);  }  /**   * Creates a new JOptionPane object using the given message, messageType,   * optionType, icon and options.   *   * @param message The message to display.   * @param messageType The type of message.   * @param optionType The type of options.   * @param icon The icon to display.   * @param options The options given.   */  public JOptionPane(Object message, int messageType, int optionType,                     Icon icon, Object[] options)  {    this(message, messageType, optionType, icon, options, null);  }  /**   * Creates a new JOptionPane object using the given message, messageType,   * optionType, icon, options and initialValue. The initialValue will be   * focused initially.   *   * @param message The message to display.   * @param messageType The type of message.   * @param optionType The type of options.   * @param icon The icon to display.   * @param options The options given.   * @param initialValue The component to focus on initially.   *   * @throws IllegalArgumentException If the messageType or optionType are not   *         legal values.   */  public JOptionPane(Object message, int messageType, int optionType,                     Icon icon, Object[] options, Object initialValue)  {    this.message = message;    if (! validMessageType(messageType))      throw new IllegalArgumentException("Message Type not legal value.");    this.messageType = messageType;    if (! validOptionType(optionType))      throw new IllegalArgumentException("Option Type not legal value.");    this.optionType = optionType;    this.icon = icon;    this.options = options;    this.initialValue = initialValue;    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));    updateUI();  }  /**   * This method creates a new JDialog that is either centered around the   * parent's frame or centered on the screen (if the parent is null). The   * JDialog will not be resizable and will be modal. Once the JDialog is   * disposed, the inputValue and value properties will  be set by the   * optionPane.   *   * @param parentComponent The parent of the Dialog.   * @param title The title in the bar of the JDialog.   *   * @return A new JDialog based on the JOptionPane configuration.   */  public JDialog createDialog(Component parentComponent, String title)  {    Frame toUse = getFrameForComponent(parentComponent);    if (toUse == null)      toUse = getRootFrame();    JDialog dialog = new JDialog(toUse, title);    inputValue = UNINITIALIZED_VALUE;    value = UNINITIALIZED_VALUE;    dialog.getContentPane().add(this);    dialog.setModal(true);    dialog.setResizable(false);    dialog.pack();    dialog.setLocationRelativeTo(parentComponent);        return dialog;  }  /**   * This method creates a new JInternalFrame that is in the JLayeredPane   * which contains the parentComponent given. If no suitable JLayeredPane   * can be found from the parentComponent given, a RuntimeException will be   * thrown.   *   * @param parentComponent The parent to find a JDesktopPane from.   * @param title The title of the JInternalFrame.   *   * @return A new JInternalFrame based on the JOptionPane configuration.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -