java displays a dialog box

An error dialog box is displayed, the message 'alert':

JOptionPane.showMessageDialog(null, "alert", "alert", JOptionPane.ERROR_MESSAGE); 

Here Insert Picture Description

Internal information display box contains "Information" message:

  JOptionPane.showInternalMessageDialog(frame, "information",
             "information", JOptionPane.INFORMATION_MESSAGE); 

Here Insert Picture Description
Note that this is an internal box, you can not drag out the layout of the parent

Display option Yes / No and the message "Select a panel of information:

  JOptionPane.showConfirmDialog(null,
             "choose one", "choose one", JOptionPane.YES_NO_OPTION);

Here Insert Picture Description
This method can return int, if you click yes, returns 0, click No, it returns 1, in order to define the user's choice

Display internal information dialog box with options Yes / No / Cancel, and "Please select a" and title information:

  JOptionPane.showInternalConfirmDialog(frame,
             "please choose one", "information",
             JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE); 

Here Insert Picture Description
It is also only a drag in the panel or dialog box jframe

Displays a warning dialog box that contains options OK, CANCEL, the title 'Warning' and the message 'Click OK to continue':

  Object[] options = { "OK", "CANCEL" };
 JOptionPane.showOptionDialog(null, "Click OK to continue", "Warning",
             JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE,
             null, options, options[0]); 

Here Insert Picture Description

Display a dialog box asking the user to enter a string:

String inputValue = JOptionPane.showInputDialog("Please input a value"); 

Here Insert Picture Description

Display a dialog box asking the user to select a character string:

  Object[] possibleValues = { "First", "Second", "Third" };
 Object selectedValue = JOptionPane.showInputDialog(null,
             "Choose one", "Input",
             JOptionPane.INFORMATION_MESSAGE, null,
             possibleValues, possibleValues[0]); 

Here Insert Picture Description

reference

JDK1.6 Chinese Documents

Published 200 original articles · won praise 99 · views 40000 +

Guess you like

Origin blog.csdn.net/weixin_43889841/article/details/103357403