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

📄 joptionpane.html

📁 API資料大全
💻 HTML
📖 第 1 页 / 共 5 页
字号:
 <dt>Show a dialog asking the user to type in a String: <dd><code> String inputValue = JOptionPane.showInputDialog("Please input a value"); </code><p> <dt>Show a dialog asking the user to select a String: <dd><code> Object[] possibleValues = { "First", "Second", "Third" };<br> Object selectedValue = JOptionPane.showInputDialog(null,             <ul><ul>"Choose one", "Input",</ul></ul>             <ul><ul>JOptionPane.INFORMATION_MESSAGE, null,</ul></ul>             <ul><ul>possibleValues, possibleValues[0]);</ul></ul> </code><p> </dl> <b>Direct Use:</b><br> To create and use an <code>JOptionPane</code> directly, the standard pattern is roughly as follows: <pre>     JOptionPane pane = new JOptionPane(<i>arguments</i>);     pane.set<i>.Xxxx(...); // Configure</i>     JDialog dialog = pane.createDialog(<i>parentComponent, title</i>);     dialog.show();     Object selectedValue = pane.getValue();     if(selectedValue == null)       return CLOSED_OPTION;     <i>//If there is <b>not</b> an array of option buttons:</i>     if(options == null) {       if(selectedValue instanceof Integer)          return ((Integer)selectedValue).intValue();       return CLOSED_OPTION;     }     <i>//If there is an array of option buttons:</i>     for(int counter = 0, maxCounter = options.length;        counter < maxCounter; counter++) {        if(options[counter].equals(selectedValue))        return counter;     }     return CLOSED_OPTION; </pre> <p> For the keyboard keys used by this component in the standard Look and Feel (L&F) renditions, see the <a href="doc-files/Key-Index.html#JOptionPane">JOptionPane</a> key assignments. <p> <strong>Warning:</strong> Serialized objects of this class will not be compatible with  future Swing releases.  The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing.  A future release of Swing will provide support for long term persistence.<P><DL><DT><B>See Also: </B><DD><A HREF="../../javax/swing/JInternalFrame.html"><CODE>JInternalFrame</CODE></A>, <A HREF="../../serialized-form.html#javax.swing.JOptionPane">Serialized Form</A></DL><HR><P><!-- ======== INNER CLASS SUMMARY ======== --><A NAME="inner_class_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Inner Class Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>protected &nbsp;class</CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/swing/JOptionPane.AccessibleJOptionPane.html">JOptionPane.AccessibleJOptionPane</A></B></CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;This class implements accessibility support for the  <code>JOptionPane</code> class.</TD></TR></TABLE>&nbsp;<A NAME="inner_classes_inherited_from_class_javax.swing.JComponent"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"><TD><B>Inner classes inherited from class javax.swing.<A HREF="../../javax/swing/JComponent.html">JComponent</A></B></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><A HREF="../../javax/swing/JComponent.AccessibleJComponent.html">JComponent.AccessibleJComponent</A></CODE></TD></TR></TABLE>&nbsp;<A NAME="inner_classes_inherited_from_class_java.awt.Container"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"><TD><B>Inner classes inherited from class java.awt.<A HREF="../../java/awt/Container.html">Container</A></B></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><A HREF="../../java/awt/Container.AccessibleAWTContainer.html">Container.AccessibleAWTContainer</A></CODE></TD></TR></TABLE>&nbsp;<A NAME="inner_classes_inherited_from_class_java.awt.Component"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"><TD><B>Inner classes inherited from class java.awt.<A HREF="../../java/awt/Component.html">Component</A></B></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><A HREF="../../java/awt/Component.AccessibleAWTComponent.html">Component.AccessibleAWTComponent</A></CODE></TD></TR></TABLE>&nbsp;<!-- =========== FIELD SUMMARY =========== --><A NAME="field_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Field Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static&nbsp;int</CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/swing/JOptionPane.html#CANCEL_OPTION">CANCEL_OPTION</A></B></CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Return value from class method if CANCEL is chosen.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static&nbsp;int</CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/swing/JOptionPane.html#CLOSED_OPTION">CLOSED_OPTION</A></B></CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Return value from class method if user closes window without selecting anything, more than likely this should be treated as either a CANCEL_OPTION or NO_OPTION.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static&nbsp;int</CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/swing/JOptionPane.html#DEFAULT_OPTION">DEFAULT_OPTION</A></B></CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Type meaning Look and Feel should not supply any options -- only use the options from the JOptionPane.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static&nbsp;int</CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/swing/JOptionPane.html#ERROR_MESSAGE">ERROR_MESSAGE</A></B></CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Used for error messages.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>protected &nbsp;<A HREF="../../javax/swing/Icon.html">Icon</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/swing/JOptionPane.html#icon">icon</A></B></CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Icon used in pane.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static&nbsp;<A HREF="../../java/lang/String.html">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/swing/JOptionPane.html#ICON_PROPERTY">ICON_PROPERTY</A></B></CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Bound property name for icon.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static&nbsp;int</CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/swing/JOptionPane.html#INFORMATION_MESSAGE">INFORMATION_MESSAGE</A></B></CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Used for information messages.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static&nbsp;<A HREF="../../java/lang/String.html">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/swing/JOptionPane.html#INITIAL_SELECTION_VALUE_PROPERTY">INITIAL_SELECTION_VALUE_PROPERTY</A></B></CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Bound property name for initialSelectionValue.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static&nbsp;<A HREF="../../java/lang/String.html">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/swing/JOptionPane.html#INITIAL_VALUE_PROPERTY">INITIAL_VALUE_PROPERTY</A></B></CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Bounds property name for initialValue.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>protected &nbsp;<A HREF="../../java/lang/Object.html">Object</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/swing/JOptionPane.html#initialSelectionValue">initialSelectionValue</A></B></CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Initial value to select in selectionValues.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>protected &nbsp;<A HREF="../../java/lang/Object.html">Object</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/swing/JOptionPane.html#initialValue">initialValue</A></B></CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Value that should be initialy selected in options.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static&nbsp;<A HREF="../../java/lang/String.html">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/swing/JOptionPane.html#INPUT_VALUE_PROPERTY">INPUT_VALUE_PROPERTY</A></B></CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Bound property name for inputValue.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>protected &nbsp;<A HREF="../../java/lang/Object.html">Object</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/swing/JOptionPane.html#inputValue">inputValue</A></B></CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Value the user has input.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>protected &nbsp;<A HREF="../../java/lang/Object.html">Object</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/swing/JOptionPane.html#message">message</A></B></CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Message to display.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static&nbsp;<A HREF="../../java/lang/String.html">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/swing/JOptionPane.html#MESSAGE_PROPERTY">MESSAGE_PROPERTY</A></B></CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Bound property name for message.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static&nbsp;<A HREF="../../java/lang/String.html">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/swing/JOptionPane.html#MESSAGE_TYPE_PROPERTY">MESSAGE_TYPE_PROPERTY</A></B></CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Bounds property name for type.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>protected &nbsp;int</CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/swing/JOptionPane.html#messageType">messageType</A></B></CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Message type.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor">

⌨️ 快捷键说明

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