1
我正在做一个小程序,我做了一个try catch块,当程序从三个文本域中获取文本时,如果任何文本域不是整数,它应显示一个对话框提示输入无效,但是,没有显示出来,我不知道如何将对话框添加到我的小应用程序我的尝试捕获不显示警告消息
try{
if (e.getSource() == bttn)
{
as=T1.getText();
ag=T2.getText();
ab=T3.getText();
as=as.trim();
ag=ag.trim();
ab=ab.trim();
redColor= Integer.parseInt(as);
greenColor= Integer.parseInt(ag);
blueColor= Integer.parseInt(ab);
}
}
catch (InputMismatchException exception){
JOptionPane.showMessageDialog(null,"Invalid Input","TITLE",JOptionPane.WARNING_MESSAGE);
}
我以前也试过,没有任何反应 –
我爱你,最后它的作品我一直在试图做到这一点,因为从昨天开始,非常感谢你 –