【发布时间】:2014-04-16 20:34:20
【问题描述】:
我正在构建一个简单的聊天应用程序,我正在考虑通过 JOptionPane 设置服务器地址和端口,我要做的是检查用户在设置端口号时没有输入字母,
int port=Integer.parseInt(JOptionPane.showInputDialog("Please insert the default port!");
我尝试使用 try/catch 块来处理它,但没有成功,有什么建议吗?
【问题讨论】:
-
“我试图用 try/catch 块处理它,但没有用”是什么意思?
-
try{code}catch(inputmismatchexception){}@BackSlash -
什么没用?
-
它显示了一个错误,但是我刚刚修复了它,无论如何谢谢 :) 而不是 inputmismatchexception 它需要 numberformat 异常
标签: java swing joptionpane