Recently, I am doing school curriculum design. Java programming requires a dialog box to pop up. The first reaction is alert and confirm in js. Java's words are instantly confused. Please read the following to summarize the learning as follows.
1. Display an error dialog box, and the message displayed by the dialog box is 'alert':
JOptionPane.showMessageDialog(null, "alert", "alert", JOptionPane.ERROR_MESSAGE);
2. Display an internal information dialog box with message 'information':
JOptionPane.showInternalMessageDialog(frame, "information","information", JOptionPane.INFORMATION_MESSAGE);
3. Display a message panel with options "yes/no" and message with 'choose one':
JOptionPane.showConfirmDialog(null, "choose one", "choose one", JOptionPane.YES_NO_OPTION);
4. Display an internal information dialog box with options "yes/no/cancel", message with 'please choose one', and title information:
JOptionPane.showInternalConfirmDialog(frame, "please choose one", "information", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE);
5. Display a warning dialog with options OK, CANCEL, title 'Warning', and 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]); 6. Display a dialog box that requires the user to type String:
String inputValue = JOptionPane.showInputDialog("Please input a value"); 7. Display a dialog box that requires the user to select String:
Object[] possibleValues = { "First", "Second", "Third" }; Object selectedValue = JOptionPane.showInputDialog(null, "Choose one", "Input", JOptionPane.INFORMATION_MESSAGE, null, possibleValues, possibleValues[0]);The above is the full content of the pop-up method of dialog boxes in Java brought to you by the editor. I hope everyone will support Wulin.com more~