Home > 类库下载 > java类库 > body text

Popup of dialog box in Java

高洛峰
Release: 2016-10-15 15:20:32
Original
1931 people have browsed it

I am currently designing a school curriculum. Java programming requires the use of dialog pop-ups. The first reaction is the alert and confirm in js. When it comes to Java, I am instantly confused. Check out the study summary as follows for future study

1. Display a Error dialog box, the message displayed in the dialog box is 'alert':

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

2. Display an internal information dialog box, whose message is 'information':

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

3. Display an information panel with options "yes/no" and message "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" and message "please choose" one', and has title information:

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

5. Display a warning dialog box with options is OK, CANCEL, title is 'Warning', message is '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 asking the user to type String:

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

7. Display a dialog box asking the user to select a String:

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


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template