鍍金池/ 教程/ Java/ Swing JOptionPane
Swing JRadioButton
Swing Layout布局
Swing JTextField
Swing JLabel
Swing開發(fā)環(huán)境安裝
Swing JComponent類
SWING ActionEvent事件類
Swing JScrollBar
Swing教程首頁
Swing JFileChooser
SWING ContainerEvent事件處理類
Swing AdjustmentListener接口
Swing WindowAdapter類
SWING ComponentListener接口
Swing JMenuBar類
Swing JPanel類及實(shí)例
Swing
SWING AdjustmentEvent事件處理
Swing JWindow類及實(shí)例
Swing介紹
Swing MouseMotionAdapter類
SWING WindowEvent事件類
Swing ItemListener接口
SWING MouseEvent事件類
Swing JMenu類
SWING KeyEvent事件類
Swing MouseMotionListener接口
Swing JProgressBar
SWING AWTEvent事件類
Swing JRadioButtonMenuItem類及例子
Swing KeyAdapter類
SWING ActionListener接口
Swing LayoutManager接口
SWING MouseMotionEvent事件處理
Swing Component類
Swing Container類
Swing CardLayout布局
Swing MouseAdapter類
Swing JSlider
Swing KeyListener接口
Swing FocusAdapter類
Swing JColorChooser
Swing ImageIcon
Swing JComboBox
Swing GroupLayout布局類
Swing JOptionPane
Swing GridBagLayout布局類
Swing JMenuItem類
Swing MouseListener Interface
Swing事件適配器
SWING ComponentEvent處理類
SWING PaintEvent事件類
Swing FlowLayout布局類
SWING Event事件類
Swing FocusListener接口
Swing控件
Swing JButton
Swing JCheckBox
Swing SpringLayout布局類
Swing容器
Swing事件處理
Swing事件監(jiān)聽器
Swing Menu菜單類
Swing JList
Swing ContainerListener接口
Swing LayoutManager2接口
Swing JFrame類和實(shí)例
Swing JTextArea
SWING InputEvent事件類
Swing BorderLayout布局
Swing WindowListener接口
Swing JCheckboxMenuItem類及例子
Swing JSpinner
Swing GridLayout布局類
Swing JPopupMenu類及實(shí)例

Swing JOptionPane

JOptionPane 類一個組件,它提供了標(biāo)準(zhǔn)的方法,彈出一個標(biāo)準(zhǔn)的對話框,或者通知用戶的東西。

類聲明

以下是聲明 javax.swing.JOptionPane類:

public class JOptionPane
   extends JComponent
      implements Accessible

字段域

以下是javax.swing.JOptionPane類的字段:

  • static int CANCEL_OPTION --Return value from class method if CANCEL is chosen.

  • static int CLOSED_OPTION --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.

  • static int DEFAULT_OPTION --Type meaning Look and Feel should not supply any options -- only use the options from the JOptionPane.

  • static int ERROR_MESSAGE --Used for error messages.

  • protected Icon icon --Icon used in pane.

  • static string ICON_PROPERTY --Bound property name for icon.

  • static int INFORMATION_MESSAGE --Used for information messages.

  • static string INITIAL_SELECTION_VALUE_PROPERTY --Bound property name for initialSelectionValue.

  • static string INITIAL_VALUE_PROPERTY --Bound property name for initialValue.

  • protected Object initialSelectionValue --Initial value to select in selectionValues.

  • protected Object initialValue --Value that should be initially selected in options.

  • static string INPUT_VALUE_PROPERTY --Bound property name for inputValue.

  • protected Object inputValue --Value the user has input.

  • protected Object message --Message to display.

  • static string MESSAGE_PROPERTY --Bound property name for message.

  • static string MESSAGE_TYPE_PROPERTY --Bound property name for type.

  • protected int messageType --Message type.

  • static int NO_OPTION --Return value from class method if NO is chosen.

  • static int OK_CANCEL_OPTION --Type used for showConfirmDialog.

  • static int OK_OPTION --Return value form class method if OK is chosen.

  • static string OPTION_TYPE_PROPERTY --Bound property name for optionType.

  • protected Object[] options --Options to display to the user.

  • static string OPTIONS_PROPERTY --Bound property name for option.

  • protected int optionType --Option type, one of DEFAULT_OPTION, YES_NO_OPTION, YES_NO_CANCEL_OPTION or OK_CANCEL_OPTION.

  • static int PLAIN_MESSAGE --No icon is used.

  • static int QUESTION_MESSAGE --Used for questions.

  • static string SELECTION_VALUES_PROPERTY --Bound property name for selectionValues.

  • protected Object[] selectionValues --Array of values the user can choose from.

  • static Object UNINITIALIZED_VALUE --Indicates that the user has not yet selected a value.

  • protected Object value --Currently selected value, will be a valid option, or UNINITIALIZED_VALUE or null.

  • static string VALUE_PROPERTY --Bound property name for value.

  • static string WANTS_INPUT_PROPERTY --Bound property name for wantsInput.

  • protected boolean wantsInput --If true, a UI widget will be provided to the user to get input.

  • static int WARNING_MESSAGE --Used for warning messages.

  • static int YES_NO_CANCEL_OPTION --Type used for showConfirmDialog.

  • static int YES_NO_OPTION --Type used for showConfirmDialog.

  • static int YES_OPTION --Return value from class method if YES is chosen.

類構(gòu)造函數(shù)

S.N. 構(gòu)造函數(shù) & 描述
1 JOptionPane() 
Creates a JOptionPane with a test message.
2 JOptionPane(Object message) 
Creates a instance of JOptionPane to display a message using the plain-message message type and the default options delivered by the UI.
3 JOptionPane(Object message, int messageType) 
Creates an instance of JOptionPane to display a message with the specified message type and the default options
4 JOptionPane(Object message, int messageType, int optionType) 
Creates an instance of JOptionPane to display a message with the specified message type and options.
5 JOptionPane(Object message, int messageType, int optionType, Icon icon) 
Creates an instance of JOptionPane to display a message with the specified message type, options, and icon.
6 JOptionPane(Object message, int messageType, int optionType, Icon icon, Object[] options)
Creates an instance of JOptionPane to display a message with the specified message type, icon, and options.
7 JOptionPane(Object message, int messageType, int optionType, Icon icon, Object[] options, Object initialValue)
Creates an instance of JOptionPane to display a message with the specified message type, icon, and options, with the initially-selected option specified.

類方法

S.N. 方法 & 描述
1 JDialog createDialog(Component parentComponent, String title) 
Creates and returns a new JDialog wrapping this centered on the parentComponent in the parentComponent's frame.
2 JDialog createDialog(String title) 
Creates and returns a new parentless JDialog with the specified title.
3 JInternalFrame createInternalFrame(Component parentComponent, String title) 
Creates and returns an instance of JInternalFrame.
4 AccessibleContext getAccessibleContext() 
Returns the AccessibleContext associated with this JOptionPane.
5 static JDesktopPane getDesktopPaneForComponent(Component parentComponent) 
Returns the specified component's desktop pane.
6 static Frame getFrameForComponent(Component parentComponent) 
Returns the specified component's Frame.
7 Icon getIcon() 
Returns the icon this pane displays.
8 Object getInitialSelectionValue() 
Returns the input value that is displayed as initially selected to the user.
9 Object getInitialValue() 
Returns the initial value.
10 Object getInputValue() 
Returns the value the user has input, if wantsInput is true.
11 int getMaxCharactersPerLineCount() 
Returns the maximum number of characters to place on a line in a message.
12 Object getMessage() 
Returns the message-object this pane displays.
13 int getMessageType() 
Returns the message type.
14 Object[] getOptions() 
Returns the choices the user can make.
15 int getOptionType() 
Returns the type of options that are displayed.
16 static Frame getRootFrame() 
Returns the Frame to use for the class methods in which a frame is not provided.
17 Object[] getSelectionValues() 
Returns the input selection values.
18 OptionPaneUI getUI() 
Returns the UI object which implements the L&F for this component.
19 String getUIClassID() 
Returns the name of the UI class that implements the L&F for this component.
20 Object getValue() 
Returns the value the user has selected.
21 boolean getWantsInput() 
Returns the value of the wantsInput property.
22 protected String paramString() 
Returns a string representation of this JOptionPane.
23 void selectInitialValue() 
Requests that the initial value be selected, which will set focus to the initial value.
24 void setIcon(Icon newIcon) 
Sets the icon to display.
25 void setInitialSelectionValue(Object newValue) 
Sets the input value that is initially displayed as selected to the user.
26 void setInitialValue(Object newInitialValue) 
Sets the initial value that is to be enabled -- the Component that has the focus when the pane is initially displayed.
27 void setInputValue(Object newValue) 
Sets the input value that was selected or input by the user.
28 void setMessage(Object newMessage) 
Sets the option pane's message-object.
29 void setMessageType(int newType) 
Sets the option pane's message type.
30 void setOptions(Object[] newOptions) 
Sets the options this pane displays.
31 void setOptionType(int newType) 
Sets the options to display.
32 static voidsetRootFrame(Frame newRootFrame) 
Sets the frame to use for class methods in which a frame is not provided.
33 void setSelectionValues(Object[] newValues) 
Sets the input selection values for a pane that provides the user with a list of items to choose from.
34 void setUI(OptionPaneUI ui) 
Sets the UI object which implements the L&F for this component.
35 void setValue(Object newValue) 
Sets the value the user has chosen.
36 void setWantsInput(boolean newValue) 
Sets the wantsInput property.
37 static int showConfirmDialog(Component parentComponent, Object message) 
Brings up a dialog with the options Yes, No and Cancel; with the title, Select an Option.
38 static int showConfirmDialog(Component parentComponent, Object message, String title, int optionType) 
Brings up a dialog where the number of choices is determined by the optionType parameter.
39 static int showConfirmDialog(Component parentComponent, Object message, String title, int optionType, int messageType) 
Brings up a dialog where the number of choices is determined by the optionType parameter, where the messageType parameter determines the icon to display.
40 static int showConfirmDialog(Component parentComponent, Object message, String title, int optionType, int messageType, Icon icon) 
Brings up a dialog with a specified icon, where the number of choices is determined by the optionType parameter.
41 static String showInputDialog(Component parentComponent, Object message) 
Shows a question-message dialog requesting input from the user parented to parentComponent.
42 static String showInputDialog(Component parentComponent, Object message, Object initialSelectionValue)