14. 56. 7. 使用JOptionPane显示一条消息 |
|
You use the JOptionPane class's showMessageDialog method to display a message.
There are three overloads of this method.
|
|
public static void showMessageDialog (java.awt.Component parent, java.lang.Object message)
public static void showMessageDialog (java.awt.Component parent, java.lang.Object message, java.lang.String title, int messageType)
public static void showMessageDialog (java.awt.Component parent, java.lang.Object message, java.lang.java.lang.String title, int messageType, Icon icon)
|
|
The messageType argument can be assigned one of these static finals: |
- JOptionPane.ERROR_MESSAGE
- JOptionPane.INFORMATION_MESSAGE
- JOptionPane.WARNING_MESSAGE
- JOptionPane.QUESTION_MESSAGE
- JOptionPane.PLAIN_MESSAGE (no icon will be used)
|
For example, the following code displays four different JOptionPane dialogs. |
JOptionPane.showMessageDialog (null, "Message", "Title", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog (null, "Message", "Title", JOptionPane.WARNING_MESSAGE);
JOptionPane.showMessageDialog (null, "Message", "Title", JOptionPane.ERROR_MESSAGE);
|
|