我想在出现异常时发出警报,例如在代码中:
try
{
//the code here
}
catch(Exception e)
{
//show an alert dialog here
}
Run Code Online (Sandbox Code Playgroud)
我需要一个示例或代码片段.
use*_*315 21
你可以用JOptionPane.showMessageDialog与WARNING_MESSAGE:
JOptionPane.showMessageDialog(yourFrame,
"WARNING.",
"Warning",
JOptionPane.WARNING_MESSAGE);
Run Code Online (Sandbox Code Playgroud)
有关如何在此处进行对话的更多信息.
小智 6
试试这个:
JOptionPane.showMessageDialog(null, "My Goodness, this is so concise");
Run Code Online (Sandbox Code Playgroud)
如果您静态导入JOptionPane.showMessageDialog,则进一步减少为
showMessageDialog(null, "This language just gets better and better!");
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
23086 次 |
| 最近记录: |