|
JavaTM Platform Standard Ed. 6 |
|||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JOptionPane
public class JOptionPane
JOptionPane 有助于方便地弹出要求用户提供值或向其发出通知的标准对话框。有关使用 JOptionPane 的信息,请参见 The Java Tutorial 中的 How to Make Dialogs 一节。
虽然由于方法数多使 JOptionPane 类可能显得复杂,但几乎所有此类的使用都是对下列静态 showXxxDialog 方法之一的单行调用:
所有这些方法还可能以
方法名 描述 showConfirmDialog 询问一个确认问题,如 yes/no/cancel。 showInputDialog 提示要求某些输入。 showMessageDialog 告知用户某事已发生。 showOptionDialog 上述三项的大统一 (Grand Unification)。
showInternalXXX 风格出现,该风格使用内部窗体来保存对话框(请参见
JInternalFrame)。此外还定义了多种便捷方法,这些方法重载那些基本方法,使用不同的参数列表。
所有对话框都是有模式的。在用户交互完成之前,每个 showXxxDialog 方法都一直阻塞调用者。
| 图标 | 消息 |
| 输入值 | |
| 选项按钮 | |
ComponentOrientation 属性。
参数:
这些方法的参数遵守一致的模式:
- parentComponent
- 定义作为此对话框的父对话框的
Component。通过两种方式使用此参数:包含它的Frame可以用作对话框的父Frame,在对话框的位置使用其屏幕坐标。一般情况下,将对话框紧靠组件置于其之下。此参数可以为null,在这种情况下,默认的Frame用作父级,并且对话框将居中位于屏幕上(取决于 L&F)。- message
- 要置于对话框中的描述消息。在最常见的应用中,message 就是一个
String或String常量。不过,此参数的类型实际上是Object。其解释依赖于其类型:
- Object[]
- 对象数组被解释为在纵向堆栈中排列的一系列 message(每个对象一个)。解释是递归式的,即根据其类型解释数组中的每个对象。
- Component
- 该
Component在对话框中显示。- Icon
- 该
Icon被包装在JLabel中并在对话框中显示。- 其他
- 该对象通过调用其
toString方法被转换为String。结果被包装在JLabel中显示。- messageType
- 定义 message 的样式。外观管理器根据此值对对话框进行不同地布置,并且通常提供默认图标。可能的值为:
ERROR_MESSAGEINFORMATION_MESSAGEWARNING_MESSAGEQUESTION_MESSAGEPLAIN_MESSAGE- optionType
- 定义在对话框的底部显示的选项按钮的集合:
用户并非仅限于使用此选项按钮集合。使用 options 参数可以提供想使用的任何按钮。
DEFAULT_OPTIONYES_NO_OPTIONYES_NO_CANCEL_OPTIONOK_CANCEL_OPTION- options
- 将在对话框底部显示的选项按钮集合的更详细描述。options 参数的常规值是
String数组,但是参数类型是Object数组。根据对象的以下类型为每个对象创建一个按钮:
- Component
- 该组件被直接添加到按钮行中。
- Icon
- 创建的
JButton以此图标作为其标签。- 其他
- 该
Object通过使用其toString方法转换为字符串,并使用该结果作为JButton的标签。- icon
- 要置于对话框中的装饰性图标。图标的默认值由
messageType参数确定。- title
- 对话框的标题。
- initialValue
- 默认选择(输入值)。
当选择更改时,调用生成 PropertyChangeEvent 的 setValue 方法。
如果已为所有输入 setWantsInput 配置了 JOptionPane,则还可以侦听绑定属性 JOptionPane.INPUT_VALUE_PROPERTY,以确定何时用户输入或选择了值。
当其中一个 showXxxDialog 方法返回整数时,可能的值为:
YES_OPTION NO_OPTION CANCEL_OPTION OK_OPTION CLOSED_OPTION JOptionPane.showMessageDialog(null, "alert", "alert", JOptionPane.ERROR_MESSAGE);
JOptionPane.showInternalMessageDialog(frame, "information",
"information", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showConfirmDialog(null,
"choose one", "choose one", JOptionPane.YES_NO_OPTION);
JOptionPane.showInternalConfirmDialog(frame,
"please choose one", "information",
JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE);
Object[] options = { "OK", "CANCEL" };
JOptionPane.showOptionDialog(null, "Click OK to continue", "Warning",
JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE,
null, options, options[0]);
String inputValue = JOptionPane.showInputDialog("Please input a value");
Object[] possibleValues = { "First", "Second", "Third" };
Object selectedValue = JOptionPane.showInputDialog(null,
"Choose one", "Input",
JOptionPane.INFORMATION_MESSAGE, null,
possibleValues, possibleValues[0]);
JOptionPane,标准模式大致如下:
JOptionPane pane = new JOptionPane(arguments);
pane.set.Xxxx(...); // Configure
JDialog dialog = pane.createDialog(parentComponent, title);
dialog.show();
Object selectedValue = pane.getValue();
if(selectedValue == null)
return CLOSED_OPTION;
//If there is not an array of option buttons:
if(options == null) {
if(selectedValue instanceof Integer)
return ((Integer)selectedValue).intValue();
return CLOSED_OPTION;
}
//If there is an array of option buttons:
for(int counter = 0, maxCounter = options.length;
counter < maxCounter; counter++) {
if(options[counter].equals(selectedValue))
return counter;
}
return CLOSED_OPTION;
警告:Swing 不是线程安全的。有关更多信息,请参阅 Swing's Threading Policy。
警告:此类的序列化对象与以后的 Swing 版本不兼容。当前序列化支持适用于短期存储,或适用于在运行相同 Swing 版本的应用程序之间进行 RMI(Remote Method Invocation,远程方法调用)。从 1.4 版本开始,已在 java.beans 包中添加了支持所有 JavaBeansTM 长期存储的功能。请参见 XMLEncoder。
JInternalFrame
| 嵌套类摘要 | |
|---|---|
protected class |
JOptionPane.AccessibleJOptionPane 此类实现对 JOptionPane 类的可访问性支持。 |
| 从类 javax.swing.JComponent 继承的嵌套类/接口 |
|---|
JComponent.AccessibleJComponent |
| 从类 java.awt.Container 继承的嵌套类/接口 |
|---|
Container.AccessibleAWTContainer |
| 从类 java.awt.Component 继承的嵌套类/接口 |
|---|
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy |
| 字段摘要 | |
|---|---|
static int |
CANCEL_OPTION 选择 CANCEL 时从类方法返回的值。 |
static int |
CLOSED_OPTION 用户没有做出任何选择而关闭了窗口时从类方法返回的值,很可能将此值视为 CANCEL_OPTION 或 NO_OPTION。 |
static int |
DEFAULT_OPTION 意味着外观不应该提供任何选项的类型,即仅使用取自 JOptionPane 的选项。 |
static int |
ERROR_MESSAGE 用于错误消息。 |
protected Icon |
icon 在窗格中使用的图标。 |
static String |
ICON_PROPERTY icon 的绑定属性名。 |
static int |
INFORMATION_MESSAGE 用于信息消息。 |
static String |
INITIAL_SELECTION_VALUE_PROPERTY initialSelectionValue 的绑定属性名。 |
static String |
INITIAL_VALUE_PROPERTY initialValue 的绑定属性名。 |
protected Object |
initialSelectionValue 要在 selectionValues 中选择的初始值。 |
protected Object |
initialValue 应该在 options 中最初选择的值。 |
static String |
INPUT_VALUE_PROPERTY inputValue 的绑定属性名。 |
protected Object |
inputValue 用户已输入的值。 |
protected Object |
message 要显示的消息。 |
static String |
MESSAGE_PROPERTY message 的绑定属性名。 |
static String |
MESSAGE_TYPE_PROPERTY type 的绑定属性名。 |
protected int |
messageType 消息类型。 |
static int |
NO_OPTION 选择 NO 时从类方法返回的值。 |
static int |
OK_CANCEL_OPTION 用于 showConfirmDialog 的类型。 |
static int |
OK_OPTION 选择 OK 时从类方法返回的值。 |
static String |
OPTION_TYPE_PROPERTY optionType 的绑定属性名。 |
protected Object[] |
options 要向用户显示的选项。 |
static String |
OPTIONS_PROPERTY option 的绑定属性名。 |
protected int |
optionType 选项类型, DEFAULT_OPTION、YES_NO_OPTION、YES_NO_CANCEL_OPTION 或 OK_CANCEL_OPTION 之一。 |
static int |
PLAIN_MESSAGE 未使用图标。 |
static int |
QUESTION_MESSAGE 用于问题。 |
static String |
SELECTION_VALUES_PROPERTY selectionValues 的绑定属性名。 |
protected Object[] |
selectionValues 用户可以从中选择值的数组。 |
static Object |
UNINITIALIZED_VALUE 指示用户尚未选择值。 |
protected Object |
value 当前选择的值,该值将为有效选项或者 UNINITIALIZED_VALUE 或 null。 |
static String |
VALUE_PROPERTY value 的绑定属性名。 |
static String |
WANTS_INPUT_PROPERTY wantsInput 的绑定属性名。 |
protected boolean |
wantsInput 如果为 true,则向用户提供 UI 窗口小部件以获取输入。 |
static int |
WARNING_MESSAGE 用于警告消息。 |
static int |
YES_NO_CANCEL_OPTION 用于 showConfirmDialog 的类型。 |
static int |
YES_NO_OPTION 用于 showConfirmDialog 的类型。 |
static int |
YES_OPTION 选择 YES 时从类方法返回的值。 |
| 从类 javax.swing.JComponent 继承的字段 |
|---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
| 从类 java.awt.Component 继承的字段 |
|---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| 从接口 java.awt.image.ImageObserver 继承的字段 |
|---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| 构造方法摘要 | |
|---|---|
JOptionPane() 创建一个带有测试消息的 JOptionPane。 |
|
JOptionPane(Object message) 创建一个显示消息的 JOptionPane 的实例,使其使用 UI 提供的普通消息消息类型和默认选项。 |
|
JOptionPane(Object message, int messageType) 创建一个显示消息的 JOptionPane 的实例,使其具有指定的消息类型和默认选项。 |
|
JOptionPane(Object message, int messageType, int optionType) 创建一个显示消息的 JOptionPane 的实例,使其具有指定的消息类型和选项。 |
|
JOptionPane(Object message, int messageType, int optionType, Icon icon) 创建一个显示消息的 JOptionPane 的实例,使其具有指定的消息类型、选项和图标。 |
|
JOptionPane(Object message, int messageType, int optionType, Icon icon, Object[] options) 创建一个显示消息的 JOptionPane 的实例,使其具有指定的消息类型、图标和选项。 |
|
JOptionPane(Object message, int messageType, int optionType, Icon icon, Object[] options, Object initialValue) 在指定最初选择的选项的前提下,创建一个显示消息的 JOptionPane 的实例,使其具有指定的消息类型、图标和选项。 |
|
| 方法摘要 | |
|---|---|
JDialog |
createDialog(Component parentComponent, String title) 创建并返回一个新 JDialog,它在 parentComponent 窗体中的 parentComponent 中央包装 this。 |
JDialog |
createDialog(String title) 创建并返回一个新的带有指定标题的无父 JDialog。 |
JInternalFrame |
createInternalFrame(Component parentComponent, String title) 创建并返回 JInternalFrame 的实例。 |
AccessibleContext |
getAccessibleContext() 返回与此 JOptionPane 相关联的 AccessibleContext。 |
static JDesktopPane |
getDesktopPaneForComponent(Component parentComponent) 返回指定组件的桌面窗格。 |
static Frame |
getFrameForComponent(Component parentComponent) 返回指定组件的 Frame。 |
Icon |
getIcon() 返回此窗格显示的图标。 |
Object |
getInitialSelectionValue() 返回(根据最初选择)向用户显示的输入值。 |
Object |
getInitialValue() 返回初始值。 |
Object |
getInputValue() 如果 wantsInput 为 true,则返回用户已输入的值。 |
int |
getMaxCharactersPerLineCount() 返回要置于消息的行中的最大字符数。 |
Object |
getMessage() 返回此窗格显示的消息对象。 |
int |
getMessageType() 返回消息类型。 |
Object[] |
getOptions() 返回用户可以作出的选择。 |
int |
getOptionType() 返回显示的选项类型。 |
static Frame |
getRootFrame() 返回用于不提供窗体的类方法中的 Frame。 |
Object[] |
getSelectionValues() 返回输入选择值。 |
OptionPaneUI |
getUI() 返回实现此组件 L&F 的 UI 对象。 |
String |
getUIClassID() 返回实现此组件 L&F 的 UI 类的名称。 |
Object |
getValue() 返回用户所选值。 |
boolean |
getWantsInput() 返回 wantsInput 属性的值。 |
protected String |
paramString() 返回此 JOptionPane 的字符串表示形式。 |
void |
selectInitialValue() 请求选择初始值,该请求将焦点设置为初始值。 |
void |
setIcon(Icon newIcon) 设置要显示的图标。 |
void |
setInitialSelectionValue(Object newValue) 设置(根据选择)最初向用户显示的输入值。 |
void |
setInitialValue(Object newInitialValue) 设置要启用的初始值,即最初显示窗格时处于焦点状态的 Component。 |
void |
setInputValue(Object newValue) 设置由用户选择或输入的输入值。 |
void |
setMessage(Object newMessage) 设置选项窗格的消息对象。 |
void |
setMessageType(int newType) 设置选项窗格的消息类型。 |
void |
setOptions(Object[] newOptions) 设置此窗格显示的选项。 |
void |
setOptionType(int newType) 设置要显示的选项。 |
static void |
setRootFrame(Frame newRootFrame) 设置窗体,以用于不提供窗体的类方法。 |
void |
setSelectionValues(Object[] newValues) 设置窗格的输入选择值,该窗格向用户提供可以从中进行选择的项列表。 |
void |
setUI(OptionPaneUI ui) 设置实现此组件 L&F 的 UI 对象。 |
void |
setValue(Object newValue) 设置用户所选值。 |
void |
setWantsInput(boolean newValue) 设置 wantsInput 属性。 |
static int |
showConfirmDialog(Component parentComponent, Object message) 调出带有选项 Yes、No 和 Cancel 的对话框;标题为 Select an Option。 |
static int |
showConfirmDialog(Component parentComponent, Object message, String title, int optionType) 调出一个由 optionType 参数确定其中选项数的对话框。 |
static int |
showConfirmDialog(Component parentComponent, Object message, String title, int optionType, int messageType) 调用一个由 optionType 参数确定其中选项数的对话框,messageType 参数确定要显示的图标。 |
static int |
showConfirmDialog(Component parentComponent, Object message, String title, int optionType, int messageType, Icon icon) 调出一个带有指定图标的对话框,其中的选项数由 optionType 参数确定。 |
static String |
showInputDialog(Component parentComponent, Object message) 显示请求用户输入内容的问题消息对话框,它以 parentComponent 为父级。 |
static String |
showInputDialog(Component parentComponent, Object message, Object initialSelectionValue) 显示请求用户输入内容的问题消息对话框,它以 parentComponent 为父级。 |
static String |
showInputDialog(Component parentComponent, Object message, String title, int messageType) 显示请求用户输入内容的对话框,它以 parentComponent 为父级,该对话框的标题为 title,消息类型为 messageType。 |
static Object |
showInputDialog(Component parentComponent, Object message, String title, int messageType, Icon icon, Object[] selectionValues, Object initialSelectionValue) 提示用户在可以指定初始选择、可能选择及其他所有选项的模块化的对话框中输入内容。 |
static String |
showInputDialog(Object message) 显示请求用户输入的问题消息对话框。 |
static String |
showInputDialog(Object message, Object initialSelectionValue) 显示请求用户输入的问题消息对话框,它带有已初始化为 initialSelectionValue 的输入值。 |
static int |
showInternalConfirmDialog(Component parentComponent, Object message) 调出带有选项 Yes、No 和 Cancel 的内部对话框面板;标题为 Select an Option。 |
static int |
showInternalConfirmDialog(Component parentComponent, Object message, String title, int optionType) 调出一个由 optionType 参数确定其中选项数的内部对话框面板。 |
static int |
showInternalConfirmDialog(Component parentComponent, Object message, String title, int optionType, int messageType) 调出一个由 optionType 参数确定其中选项数的内部对话框面板,messageType 参数确定要显示的图标。 |
static int |
showInternalConfirmDialog(Component parentComponent, Object message, String title, int optionType, int messageType, Icon icon) 调出一个带有指定图标的内部对话框面板,其中的选项数由 optionType 参数确定。 |
static String |
showInternalInputDialog(Component parentComponent, Object message) 显示请求用户输入内容的内部问题消息对话框,它以 parentComponent 为父级。 |
static String |
showInternalInputDialog(Component parentComponent, Object message, String title, int messageType) 显示请求用户输入内容的内部对话框,它以 parentComponent 为父级。 |
static Object |
showInternalInputDialog(Component parentComponent, Object message, String title, int messageType, Icon icon, Object[] selectionValues, Object initialSelectionValue) 提示用户在可以指定初始选择、可能选择及其他所有选项的模块化的内部对话框中输入内容。 |
static void |
showInternalMessageDialog(Component parentComponent, Object message) 调出内部确认对话框面板。 |
static void |
showInternalMessageDialog(Component parentComponent, Object message, String title, int messageType) 调出一个显示消息的内部对话框面板,它使用由 messageType 参数确定的默认图标。 |
static void |
showInternalMessageDialog(Component parentComponent, Object message, String title, int messageType, Icon icon) 调出一个显示消息的内部对话框面板,为其指定了所有参数。 |
static int |
showInternalOptionDialog(Component parentComponent, Object message, String title, int optionType, int messageType, Icon icon, Object[] options, Object initialValue) 调出一个带有指定图标的内部对话框面板,其中的初始选择由 initialValue 参数确定,选项数由 optionType 参数确定。 |
static void |
showMessageDialog(Component parentComponent, Object message) 调出标题为 "Message" 的信息消息对话框。 |
static void |
showMessageDialog(Component parentComponent, Object message, String title, int messageType) 调出对话框,它显示使用由 messageType 参数确定的默认图标的 message。 |
static void |
showMessageDialog(Component parentComponent, Object message, String title, int messageType, Icon icon) 调出一个显示信息的对话框,为其指定了所有参数。 |
static int |
showOptionDialog(Component parentComponent, Object message, String title, int optionType, int messageType, Icon icon, Object[] options, Object initialValue) 调出一个带有指定图标的对话框,其中的初始选择由 initialValue 参数确定,选项数由 optionType 参数确定。 |
void |
updateUI() UIManager 发出的关于 L&F 已改变的通知。 |
| 从类 java.lang.Object 继承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| 字段详细信息 |
|---|
public static final Object UNINITIALIZED_VALUE
public static final int DEFAULT_OPTION
JOptionPane 的选项。
public static final int YES_NO_OPTION
showConfirmDialog 的类型。
public static final int YES_NO_CANCEL_OPTION
showConfirmDialog 的类型。
public static final int OK_CANCEL_OPTION
showConfirmDialog 的类型。
public static final int YES_OPTION
public static final int NO_OPTION
public static final int CANCEL_OPTION
public static final int OK_OPTION
public static final int CLOSED_OPTION
CANCEL_OPTION 或
NO_OPTION。
public static final int ERROR_MESSAGE
public static final int INFORMATION_MESSAGE
public static final int WARNING_MESSAGE
public static final int QUESTION_MESSAGE
public static final int PLAIN_MESSAGE
public static final String ICON_PROPERTY
icon 的绑定属性名。
public static final String MESSAGE_PROPERTY
message 的绑定属性名。
public static final String VALUE_PROPERTY
value 的绑定属性名。
public static final String OPTIONS_PROPERTY
option 的绑定属性名。
public static final String INITIAL_VALUE_PROPERTY
initialValue 的绑定属性名。
public static final String MESSAGE_TYPE_PROPERTY
type 的绑定属性名。
public static final String OPTION_TYPE_PROPERTY
optionType 的绑定属性名。
public static final String SELECTION_VALUES_PROPERTY
selectionValues 的绑定属性名。
public static final String INITIAL_SELECTION_VALUE_PROPERTY
initialSelectionValue 的绑定属性名。
public static final String INPUT_VALUE_PROPERTY
inputValue 的绑定属性名。
public static final String WANTS_INPUT_PROPERTY
wantsInput 的绑定属性名。
protected transient Icon icon
protected transient Object message
protected transient Object[] options
protected transient Object initialValue
options 中最初选择的值。
protected int messageType
protected int optionType
DEFAULT_OPTION、
YES_NO_OPTION、
YES_NO_CANCEL_OPTION 或
OK_CANCEL_OPTION 之一。
protected transient Object value
UNINITIALIZED_VALUE 或
null。
protected transient Object[] selectionValues
protected transient Object inputValue
protected transient Object initialSelectionValue
selectionValues 中选择的初始值。
protected boolean wantsInput
| 构造方法详细信息 |
|---|
public JOptionPane()
JOptionPane。
public JOptionPane(Object message)
JOptionPane 的实例,使其使用 UI 提供的普通消息消息类型和默认选项。
message - 要显示的
Object
public JOptionPane(Object message,
int messageType)
JOptionPane 的实例,使其具有指定的消息类型和默认选项。
message - 要显示的
Object
messageType - 要显示的消息类型:
ERROR_MESSAGE、
INFORMATION_MESSAGE、
WARNING_MESSAGE、
QUESTION_MESSAGE 或
PLAIN_MESSAGE
public JOptionPane(Object message,
int messageType,
int optionType)
JOptionPane 的实例,使其具有指定的消息类型和选项。
message - 要显示的
Object
messageType - 要显示的消息类型:
ERROR_MESSAGE、
INFORMATION_MESSAGE、
WARNING_MESSAGE、
QUESTION_MESSAGE 或
PLAIN_MESSAGE
optionType - 要在窗格中显示的选项:
DEFAULT_OPTION、
YES_NO_OPTION、
YES_NO_CANCEL_OPTION、
OK_CANCEL_OPTION
public JOptionPane(Object message,
int messageType,
int optionType,
Icon icon)
JOptionPane 的实例,使其具有指定的消息类型、选项和图标。
message - 要显示的
Object
messageType - 要显示的消息类型:
ERROR_MESSAGE、
INFORMATION_MESSAGE、
WARNING_MESSAGE、
QUESTION_MESSAGE 或
PLAIN_MESSAGE
optionType - 要在窗格中显示的选项:
DEFAULT_OPTION、
YES_NO_OPTION、
YES_NO_CANCEL_OPTION、
OK_CANCEL_OPTION
icon - 要显示的
Icon 图像
public JOptionPane(Object message,
int messageType,
int optionType,
Icon icon,
Object[] options)
JOptionPane 的实例,使其具有指定的消息类型、图标和选项。最初没有选择任何选项。
options 对象应该包含 Component(直接添加的)或 String(包装在 JButton 中)的实例。如果提供 Component,则必须确保单击 Component 时,它向创建的 JOptionPane 传递消息 setValue。
message - 要显示的
Object
messageType - 要显示的消息类型:
ERROR_MESSAGE、
INFORMATION_MESSAGE、
WARNING_MESSAGE、
QUESTION_MESSAGE 或
PLAIN_MESSAGE
optionType - 要在窗格中显示的选项:
DEFAULT_OPTION、
YES_NO_OPTION、
YES_NO_CANCEL_OPTION、
OK_CANCEL_OPTION
icon - 要显示的
Icon 图像
options - 用户可以选择的选项
public JOptionPane(Object message,
int messageType,
int optionType,
Icon icon,
Object[] options,
Object initialValue)
JOptionPane 的实例,使其具有指定的消息类型、图标和选项。
message - 要显示的
Object
messageType - 要显示的消息类型:
ERROR_MESSAGE、
INFORMATION_MESSAGE、
WARNING_MESSAGE、
QUESTION_MESSAGE 或
PLAIN_MESSAGE
optionType - 要在窗格中显示的选项:
DEFAULT_OPTION、
YES_NO_OPTION、
YES_NO_CANCEL_OPTION、
OK_CANCEL_OPTION
icon - 要显示的图标图像
options - 用户可以选择的选项
initialValue - 最初选择的选项;如果为
null,则不做最初选择;只有在使用
options 时才有意义
| 方法详细信息 |
|---|
public static String showInputDialog(Object message)
throws HeadlessException
message - 要显示的
Object
HeadlessException - 如果
GraphicsEnvironment.isHeadless 返回
true
GraphicsEnvironment.isHeadless()
public static String showInputDialog(Object message,
Object initialSelectionValue)
initialSelectionValue 的输入值。该对话框使用默认的窗体,通常意味着在屏幕上居中显示。
message - 要显示的
Object
initialSelectionValue - 用于初始化输入字段的值
public static String showInputDialog(Component parentComponent,
Object message)
throws HeadlessException
parentComponent 为父级。该对话框显示于
Component 的窗体的上部,通常位于
Component 之下。
parentComponent - 对话框的父
Component
message - 要显示的
Object
HeadlessException - 如果
GraphicsEnvironment.isHeadless 返回
true
GraphicsEnvironment.isHeadless()
public static String showInputDialog(Component parentComponent,
Object message,
Object initialSelectionValue)
parentComponent 为父级。输入值将被初始化为
initialSelectionValue。该对话框显示于
Component 的窗体的上部,通常位于
Component 之下。
parentComponent - 对话框的父
Component
message - 要显示的
Object
initialSelectionValue - 用于初始化输入字段的值
public static String showInputDialog(Component parentComponent,
Object message,
String title,
int messageType)
throws HeadlessException
parentComponent 为父级,该对话框的标题为
title,消息类型为
messageType。
parentComponent - 对话框的父
Component
message - 要显示的
Object
title - 要在对话框的标题栏中显示的
String
messageType - 要显示的消息类型:
ERROR_MESSAGE、
INFORMATION_MESSAGE、
WARNING_MESSAGE、
QUESTION_MESSAGE 或
PLAIN_MESSAGE
HeadlessException - 如果
GraphicsEnvironment.isHeadless 返回
true
GraphicsEnvironment.isHeadless()
public static Object showInputDialog(Component parentComponent,
Object message,
String title,
int messageType,
Icon icon,
Object[] selectionValues,
Object initialSelectionValue)
throws HeadlessException
selectionValues 中进行选择,其中
null 表示用户可以输入想输入的任何内容,通常依靠
JTextField 来实现。
initialSelectionValue 是用于提示用户的初始值。由 UI 决定如何最好的表示
selectionValues,但通常情况下将使用
JComboBox、
JList 或
JTextField。
parentComponent - 对话框的父
Component
message - 要显示的
Object
title - 要在对话框的标题栏中显示的
String
messageType - 要显示的消息类型:
ERROR_MESSAGE、
INFORMATION_MESSAGE、
WARNING_MESSAGE、
QUESTION_MESSAGE 或
PLAIN_MESSAGE
icon - 要显示的
Icon 图像
selectionValues - 给出可能选择的
Object 数组
initialSelectionValue - 用于初始化输入字段的值
null 意味着用户取消了输入
HeadlessException - 如果
GraphicsEnvironment.isHeadless 返回
true
GraphicsEnvironment.isHeadless()
public static void showMessageDialog(Component parentComponent,
Object message)
throws HeadlessException
parentComponent - 确定在其中显示对话框的
Frame;如果为
null 或者
parentComponent 不具有
Frame,则使用默认的
Frame
message - 要显示的
Object
HeadlessException - 如果
GraphicsEnvironment.isHeadless 返回
true
GraphicsEnvironment.isHeadless()
public static void showMessageDialog(Component parentComponent,
Object message,
String title,
int messageType)
throws HeadlessException
messageType 参数确定的默认图标的 message。
parentComponent - 确定在其中显示对话框的
Frame;如果为
null 或者
parentComponent 不具有
Frame,则使用默认的
Frame
message - 要显示的
Object
title - 对话框的标题字符串
messageType - 要显示的消息类型:
ERROR_MESSAGE、
INFORMATION_MESSAGE、
WARNING_MESSAGE、
QUESTION_MESSAGE 或
PLAIN_MESSAGE
HeadlessException - 如果
GraphicsEnvironment.isHeadless 返回
true
GraphicsEnvironment.isHeadless()
public static void showMessageDialog(Component parentComponent,
Object message,
String title,
int messageType,
Icon icon)
throws HeadlessException
parentComponent - 确定在其中显示对话框的
Frame;如果为
null 或者
parentComponent 不具有
Frame,则使用默认的
Frame
message - 要显示的
Object
title - 对话框的标题字符串
messageType - 要显示的消息类型:
ERROR_MESSAGE、
INFORMATION_MESSAGE、
WARNING_MESSAGE、
QUESTION_MESSAGE 或
PLAIN_MESSAGE
icon - 要在对话框中显示的图标,该图标可以帮助用户识别要显示的消息种类
HeadlessException - 如果
GraphicsEnvironment.isHeadless 返回
true
GraphicsEnvironment.isHeadless()
public static int showConfirmDialog(Component parentComponent,
Object message)
throws HeadlessException
parentComponent - 确定在其中显示对话框的
Frame;如果为
null 或者
parentComponent 不具有
Frame,则使用默认的
Frame
message - 要显示的
Object
HeadlessException - 如果
GraphicsEnvironment.isHeadless 返回
true
GraphicsEnvironment.isHeadless()
public static int showConfirmDialog(Component parentComponent,
Object message,
String title,
int optionType)
throws HeadlessException
optionType 参数确定其中选项数的对话框。
parentComponent - 确定在其中显示对话框的
Frame;如果为
null 或者
parentComponent 不具有
Frame,则使用默认的
Frame
message - 要显示的
Object
title - 对话框的标题字符串
optionType - 指定可用于对话框的选项的 int:
YES_NO_OPTION、
YES_NO_CANCEL_OPTION 或
OK_CANCEL_OPTION
HeadlessException - 如果
GraphicsEnvironment.isHeadless 返回
true
GraphicsEnvironment.isHeadless()
public static int showConfirmDialog(Component parentComponent,
Object message,
String title,
int optionType,
int messageType)
throws HeadlessException
optionType 参数确定其中选项数的对话框,
messageType 参数确定要显示的图标。
messageType 参数主要用于提供来自外观的默认图标。
parentComponent - 确定在其中显示对话框的
Frame;如果为
null 或者
parentComponent 不具有
Frame,则使用默认的
Frame。
message - 要显示的
Object
title - 对话框的标题字符串
optionType - 指定可用于对话框的选项的整数:
YES_NO_OPTION、
YES_NO_CANCEL_OPTION 或
OK_CANCEL_OPTION
messageType - 指定此消息种类的整数;主要用于确定来自可插入外观的图标:
ERROR_MESSAGE、
INFORMATION_MESSAGE、
WARNING_MESSAGE、
QUESTION_MESSAGE 或
PLAIN_MESSAGE
HeadlessException - 如果
GraphicsEnvironment.isHeadless 返回
true
GraphicsEnvironment.isHeadless()
public static int showConfirmDialog(Component parentComponent,
Object message,
String title,
int optionType,
int messageType,
Icon icon)
throws HeadlessException
optionType 参数确定。
messageType 参数主要用于提供来自外观的默认图标。
parentComponent - 确定在其中显示对话框的
Frame;如果为
null 或者
parentComponent 不具有
Frame,则使用默认的
Frame
message - 要显示的 Object
title - 对话框的标题字符串
optionType - 指定可用于对话框的选项的 int:
YES_NO_OPTION、
YES_NO_CANCEL_OPTION 或
OK_CANCEL_OPTION
messageType - 指定此消息种类的 int,主要用于确定来自可插入外观的图标:
ERROR_MESSAGE、
INFORMATION_MESSAGE、
WARNING_MESSAGE、
QUESTION_MESSAGE 或
PLAIN_MESSAGE
icon - 要在对话框中显示的图标
HeadlessException - 如果
GraphicsEnvironment.isHeadless 返回
true
GraphicsEnvironment.isHeadless()
public static int showOptionDialog(Component parentComponent,
Object message,
String title,
int optionType,
int messageType,
Icon icon,
Object[] options,
Object initialValue)
throws HeadlessException
initialValue 参数确定,选项数由
optionType 参数确定。
如果 optionType 为 YES_NO_OPTION 或者 YES_NO_CANCEL_OPTION,并且 options 参数为 null,则由外观提供选项。
messageType 参数主要用于提供来自外观的默认图标。
parentComponent - 确定在其中显示对话框的
Frame;如果为
null 或者
parentComponent 不具有
Frame,则使用默认的
Frame
message - 要显示的
Object
title - 对话框的标题字符串
optionType - 指定可用于对话框的选项的整数:
DEFAULT_OPTION、
YES_NO_OPTION、
YES_NO_CANCEL_OPTION 或
OK_CANCEL_OPTION
messageType - 指定消息种类的整数,主要用于确定来自可插入外观的图标:
ERROR_MESSAGE、
INFORMATION_MESSAGE、
WARNING_MESSAGE、
QUESTION_MESSAGE 或
PLAIN_MESSAGE
icon - 在对话框中显示的图标
options - 指示用户可能选择的对象组成的数组;如果对象是组件,则可以正确呈现;非
String 对象使用其
toString 方法呈现;如果此参数为
null,则由外观确定选项
initialValue - 表示对话框的默认选择的对象;只有在使用
options 时才有意义;可以为
null
CLOSED_OPTION
HeadlessException - 如果
GraphicsEnvironment.isHeadless 返回
true
GraphicsEnvironment.isHeadless()
public JDialog createDialog(Component parentComponent,
String title)
throws HeadlessException
JDialog,它在
parentComponent 窗体中的
parentComponent 中央包装
this。
title 是返回对话框的标题。用户不能调整返回的
JDialog,但是程序可以通过调用
JDialog 实例上的
setResizable 来更改此属性。返回的
JDialog 将被设置为:一旦将其关闭或者用户单击其中一个按钮,就会相应地设置选项窗格的值属性并关闭对话框。每次对话框变得可见时,它会将选项窗格的值属性重置为
JOptionPane.UNINITIALIZED_VALUE,从而确保用户的后续操作能够正确地关闭对话框。
parentComponent - 确定在其中显示对话框的窗体;如果
parentComponent 不具有
Frame,则使用默认的
Frame
title - 对话框的标题字符串
JDialog
HeadlessException - 如果
GraphicsEnvironment.isHeadless 返回
true
GraphicsEnvironment.isHeadless()
public JDialog createDialog(String title)
throws HeadlessException
JDialog。用户不能调整返回的
JDialog,但是程序可以通过调用
JDialog 实例上的
setResizable 来更改此属性。返回的
JDialog 将被设置为:一旦将其关闭或者用户单击其中一个按钮,就会相应地设置选项窗格的值属性并关闭对话框。每次对话框变得可见时,它会将选项窗格的值属性重置为
JOptionPane.UNINITIALIZED_VALUE,从而确保用户的后续动作能够正确地关闭对话框。
title - 对话框的标题字符串
JDialog
HeadlessException - 如果
GraphicsEnvironment.isHeadless 返回
true
GraphicsEnvironment.isHeadless()
public static void showInternalMessageDialog(Component parentComponent,
Object message)
parentComponent - 确定在其中显示对话框的
Frame;如果为
null 或者
parentComponent 不具有
Frame,则使用默认的
Frame
message - 要显示的对象
public static void showInternalMessageDialog(Component parentComponent,
Object message,
String title,
int messageType)
messageType 参数确定的默认图标。
parentComponent - 确定在其中显示对话框的
Frame;如果为
null 或者
parentComponent 不具有
Frame,则使用默认的
Frame
message - 要显示的
Object
title - 对话框的标题字符串
messageType - 要显示的消息类型:
ERROR_MESSAGE、
INFORMATION_MESSAGE、
WARNING_MESSAGE、
QUESTION_MESSAGE 或
PLAIN_MESSAGE
public static void showInternalMessageDialog(Component parentComponent,
Object message,
String title,
int messageType,
Icon icon)
parentComponent - 确定在其中显示对话框的
Frame;如果为
null 或者
parentComponent 不具有
Frame,则使用默认的
Frame
message - 要显示的
Object
title - 对话框的标题字符串
messageType - 要显示的消息类型:
ERROR_MESSAGE、
INFORMATION_MESSAGE、
WARNING_MESSAGE、
QUESTION_MESSAGE 或
PLAIN_MESSAGE
icon - 要在对话框中显示的图标,该图标可以帮助用户识别要显示的消息种类
public static int showInternalConfirmDialog(Component parentComponent,
Object message)
parentComponent - 确定在其中显示对话框的
Frame;如果为
null 或者
parentComponent 不具有
Frame,则使用默认的
Frame
message - 要显示的
Object
public static int showInternalConfirmDialog(Component parentComponent,
Object message,
String title,
int optionType)
optionType 参数确定其中选项数的内部对话框面板。
parentComponent - 确定在其中显示对话框的
Frame;如果为
null 或者
parentComponent 不具有
Frame,则使用默认的
Frame
message - 要在对话框中显示的对象;
Component 对象呈现为
Component;
String 对象呈现为字符串;其他对象将通过
toString 方法被转换为
String
title - 对话框的标题字符串
optionType - 指定可用于对话框的选项的整数:
YES_NO_OPTION 或
YES_NO_CANCEL_OPTION
public static int showInternalConfirmDialog(Component parentComponent,
Object message,
String title,
int optionType,
int messageType)
optionType 参数确定其中选项数的内部对话框面板,
messageType 参数确定要显示的图标。
messageType 参数主要用于提供来自外观的默认图标。
parentComponent - 确定在其中显示对话框的
Frame;如果为
null 或者
parentComponent 不具有
Frame,则使用默认的
Frame
message - 要在对话框中显示的对象;
Component 对象呈现为
Component;
String 对象呈现为字符串;其他对象将通过
toString 方法被转换为
String
title - 对话框的标题字符串
optionType - 指定可用于对话框的选项的整数:
YES_NO_OPTION 或
YES_NO_CANCEL_OPTION
messageType - 指定消息种类的整数,主要用于确定来自可插入外观的图标:
ERROR_MESSAGE、
INFORMATION_MESSAGE、
WARNING_MESSAGE、
QUESTION_MESSAGE 或
PLAIN_MESSAGE
public static int showInternalConfirmDialog(Component parentComponent,
Object message,
String title,
int optionType,
int messageType,
Icon icon)
optionType 参数确定。
messageType 参数主要用于提供来自外观的默认图标。
parentComponent - 确定在其中显示对话框的
Frame;如果为
null 或者 parentComponent 不具有 Frame,则使用默认的
Frame
message - 要在对话框中显示的对象;
Component 对象呈现为
Component;
String 对象呈现为字符串;其他对象将通过
toString 方法被转换为
String
title - 对话框的标题字符串
optionType - 指定可用于对话框的选项的整数:
YES_NO_OPTION 或
YES_NO_CANCEL_OPTION。
messageType - 指定消息种类的整数,主要用于确定来自可插入外观的图标:
ERROR_MESSAGE、
INFORMATION_MESSAGE、
WARNING_MESSAGE、
QUESTION_MESSAGE 或
PLAIN_MESSAGE
icon - 要在对话框中显示的图标
public static int showInternalOptionDialog(Component parentComponent,
Object message,
String title,
int optionType,
int messageType,
Icon icon,
Object[] options,
Object initialValue)
initialValue 参数确定,选项数由
optionType 参数确定。
如果 optionType 为 YES_NO_OPTION,或者 YES_NO_CANCEL_OPTION 且 options 参数为 null,则由外观提供选项。
messageType 参数主要用于提供来自外观的默认图标。
parentComponent - 确定在其中显示对话框的
Frame;如果为
null 或者
parentComponent 不具有
Frame,则使用默认的
Frame
message - 要在对话框中显示的对象;
Component 对象呈现为
Component;
String 对象呈现为字符串。其他对象通过
toString 方法被转换为
String
title - 对话框的标题字符串
optionType - 指定可用于对话框的选项的整数:
YES_NO_OPTION 或
YES_NO_CANCEL_OPTION
messageType - 指定消息种类的整数;主要用于确定来自可插入外观的图标:
ERROR_MESSAGE、
INFORMATION_MESSAGE、
WARNING_MESSAGE、
QUESTION_MESSAGE 或
PLAIN_MESSAGE
icon - 在对话框中显示的图标
options - 指示用户可能选择的对象组成的数组;如果对象是组件,则可以正确呈现;非
String 对象使用其
toString 方法呈现;如果此参数为
null,则由外观确定选项
initialValue - 表示对话框的默认选择的对象;只有在使用
options 时才有意义;可以为
null
CLOSED_OPTION
public static String showInternalInputDialog(Component parentComponent,
Object message)
parentComponent 为父级。该对话框显示于
Component 的窗体中,通常位于
Component 之下。
parentComponent - 对话框的父
Component
message - 要显示的
Object
public static String showInternalInputDialog(Component parentComponent,
Object message,
String title,
int messageType)
parentComponent 为父级。该对话框的标题为
title,消息类型为
messageType。
parentComponent - 对话框的父
Component
message - 要显示的
Object
title - 要在对话框的标题栏中显示的
String
messageType - 要显示的消息类型:ERROR_MESSAGE、INFORMATION_MESSAGE、WARNING_MESSAGE、QUESTION_MESSAGE 或 PLAIN_MESSAGE
public static Object showInternalInputDialog(Component parentComponent,
Object message,
String title,
int messageType,
Icon icon,
Object[] selectionValues,
Object initialSelectionValue)
selectionValues 中进行选择,其中
null 表示用户可以输入想输入的任何内容,通常依靠
JTextField 来实现。
initialSelectionValue 是用于提示用户的初始值。由 UI 决定如何最好的表示
selectionValues,但通常情况下将使用
JComboBox、
JList 或
JTextField。
parentComponent - 对话框的父
Component
message - 要显示的
Object
title - 要在对话框的标题栏中显示的
String
messageType - 要显示的消息类型:
ERROR_MESSAGE、
INFORMATION_MESSAGE、
WARNING_MESSAGE、
QUESTION_MESSAGE 或
PLAIN_MESSAGE
icon - 要显示的
Icon 图像
selectionValues - 给出可能选择的
Object 数组
initialSelectionValue - 用于初始化输入字段的值
null 意味着用户取消了输入
public JInternalFrame createInternalFrame(Component parentComponent,
String title)
JInternalFrame 的实例。内部窗体是利用指定标题创建的,同时包装了
JOptionPane。返回的
JInternalFrame 将被添加到
parentComponent 的
JDesktopPane 祖先中;如果其祖先之一不是
JDesktopPane,则添加到其父组件中;如果
parentComponent 不具有父级,则抛出
RuntimeException。
parentComponent - 内部窗体的父
Component
title - 要在窗体的标题栏中显示的
String
JOptionPane 的
JInternalFrame
RuntimeException - 如果
parentComponent 不具有有效的父级
public static Frame getFrameForComponent(Component parentComponent)
throws HeadlessException
Frame。
parentComponent - 要检查
Frame 的
Component
Frame;如果组件为
null 或者不具有有效的
Frame 父级,则返回
getRootFrame
HeadlessException - 如果
GraphicsEnvironment.isHeadless 返回
true
getRootFrame(),
GraphicsEnvironment.isHeadless()
public static JDesktopPane getDesktopPaneForComponent(Component parentComponent)
parentComponent - 要检查桌面的
Component
JDesktopPane;如果组件为
null 或者不具有作为
JInternalFrame 的祖先,则返回
null
public static void setRootFrame(Frame newRootFrame)
注: 建议提供有效的父级而不是使用此方法。
newRootFrame - 要使用的默认
Frame
public static Frame getRootFrame()
throws HeadlessException
Frame。
Frame
HeadlessException - 如果
GraphicsEnvironment.isHeadless 返回
true
setRootFrame(java.awt.Frame),
GraphicsEnvironment.isHeadless()
public void setUI(OptionPaneUI ui)
ui -
OptionPaneUI L&F 对象
UIDefaults.getUI(javax.swing.JComponent)
public OptionPaneUI getUI()
OptionPaneUI 对象
public void updateUI()
UIManager 发出的关于 L&F 已改变的通知。根据
UIManager 的最新通知替换当前的 UI 对象。
JComponent 中的
updateUI
JComponent.updateUI()
public String getUIClassID()
JComponent 中的
getUIClassID
JComponent.getUIClassID(),
UIDefaults.getUI(javax.swing.JComponent)
public void setMessage(Object newMessage)
newMessage - 要显示的
Object
getMessage()
public Object getMessage()
Object
setMessage(java.lang.Object)
public void setIcon(Icon newIcon)
null,则外观不提供图标。
newIcon - 要显示的
Icon
getIcon()
public Icon getIcon()
Icon
setIcon(javax.swing.Icon)
public void setValue(Object newValue)
newValue - 所选值
getValue()
public Object getValue()
UNINITIALIZED_VALUE 表示用户尚未作出选择,而
null 则表示用户没有选取任何项便关闭了窗口。否则,返回值将为在此对象中所定义的选项之一。
Object;如果用户尚未作出选择,则返回
UNINITIALIZED_VALUE;如果用户没有作出选择而关闭了窗口,则返回
null
setValue(java.lang.Object)
public void setOptions(Object[] newOptions)
newOptions 中的元素为
Component,则直接将其添加到窗格;否则为元素创建一个按钮。
newOptions - 用于创建用户可单击按钮的
Object 数组,或者要添加到窗格的任意
Component
getOptions()
public Object[] getOptions()
Object 数组
setOptions(java.lang.Object[])
public void setInitialValue(Object newInitialValue)
Component。
newInitialValue - 获得初始键盘焦点的
Object
getInitialValue()
public Object getInitialValue()
Object
setInitialValue(java.lang.Object)
public void setMessageType(int newType)
parentComponent 的可能布局时使用。
newType - 指定要显示的消息种类的整数:
ERROR_MESSAGE、
INFORMATION_MESSAGE、
WARNING_MESSAGE、
QUESTION_MESSAGE 或
PLAIN_MESSAGE
RuntimeException - 如果
newType 不是上面列出的合法值之一
getMessageType()
public int getMessageType()
setMessageType(int)
public void setOptionType(int newType)
newType - 指定 L&F 要显示的选项的整数:
DEFAULT_OPTION、
YES_NO_OPTION、
YES_NO_CANCEL_OPTION 或
OK_CANCEL_OPTION
RuntimeException - 如果
newType 不是上面列出的合法值之一
getOptionType(),
setOptions(java.lang.Object[])
public int getOptionType()
setOptionType(int)
public void setSelectionValues(Object[] newValues)
null 值表示用户可以输入想输入的任何值,通常依靠
JTextField 来实现。
将 wantsInput 设置为 true。使用 setInitialSelectionValue 指定最初选择的值。启用了窗格后,inputValue 将被设置为用户所选的值。
newValues - 用户要显示的
Object 数组(通常使用列表或组合框的形式),用户可以从中作出选择
setWantsInput(boolean),
setInitialSelectionValue(java.lang.Object),
getSelectionValues()
public Object[] getSelectionValues()
Object 数组
setSelectionValues(java.lang.Object[])
public void setInitialSelectionValue(Object newValue)
wantsInput 为 true 时使用。
newValue - 最初选择的值
setSelectionValues(java.lang.Object[]),
getInitialSelectionValue()
public Object getInitialSelectionValue()
setInitialSelectionValue(java.lang.Object),
setSelectionValues(java.lang.Object[])
public void setInputValue(Object newValue)
wantsInput 为 true 时才使用。注意,此方法由选项窗格内部调用(响应用户操作),客户端程序一般不能调用。要设置(根据选择)最初向用户显示的输入值,请使用
setInitialSelectionValue。
newValue - 用于设置用户指定值的
Object(通常使用文本字段的形式)
setSelectionValues(java.lang.Object[]),
setInitialSelectionValue(java.lang.Object),
setWantsInput(boolean),
getInputValue()
public Object getInputValue()
wantsInput 为 true,则返回用户已输入的值。
Object,如果它是这些对象之一;如果为键入字段中的值,则返回
String
setSelectionValues(java.lang.Object[]),
setWantsInput(boolean),
setInputValue(java.lang.Object)
public int getMaxCharactersPerLineCount()
Integer.MAX_VALUE。在子类中重写此方法可更改该值。
public void setWantsInput(boolean newValue)
wantsInput 属性。如果
newValue 为 true,则提供其父级为
parentComponent 的输入组件(比如文本字段或组合框),以允许用户输入值。如果
getSelectionValues 返回非
null 数组,则输入值为该数组中的对象之一。否则,输入值就是用户输入的内容。
这是一个绑定属性。
setSelectionValues(java.lang.Object[]),
setInputValue(java.lang.Object)
public boolean getWantsInput()
wantsInput 属性的值。
setWantsInput(boolean)
public void selectInitialValue()
protected String paramString()
JOptionPane 的字符串表示形式。此方法仅在进行调试的时候使用,对于各个实现,所返回字符串的内容和格式可能有所不同。返回的字符串可能为空,但不可能为
null。
JComponent 中的
paramString
JOptionPane 的字符串表示形式
public AccessibleContext getAccessibleContext()
AccessibleContext。对于选项窗格,
AccessibleContext 采用
AccessibleJOptionPane 的形式。必要时创建一个新的
AccessibleJOptionPane 实例。
Accessible 中的
getAccessibleContext
JComponent 中的
getAccessibleContext
|
JavaTM Platform Standard Ed. 6 |
|||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
版权所有 2007 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。另请参阅文档重新分发政策。