我正在使用if并突然写下一些代码,else表示从未使用过该分支...但是应该可以使用。
语句看起来像这样
JOptionPane.showConfirmDialog(null,full_name+"\n"+number_age+"\n"+gender+"\n"+address+
"\n"+birthday+"\n"+cell_no,"CHECK INFORMATION!",JOptionPane.YES_NO_OPTION);
if(true){
JOptionPane.showMessageDialog(null,"Thank you for Entering");
}else{
JOptionPane.showMessageDialog(null,"Please Retry");
}
答案 0 :(得分:1)
检查JOptionPane.showConfirmDialog响应并与JOptionPane.YES_NO_OPTION
进行比较:
int answer = JOptionPane.showConfirmDialog(null,full_name+"\n"+number_age+"\n"+gender+"\n"+address+
"\n"+birthday+"\n"+cell_no,"CHECK INFORMATION!",JOptionPane.YES_NO_OPTION);
if (JOptionPane.YES_OPTION == answer)) {
JOptionPane.showMessageDialog(null,"Thank you for Entering");
} else {
JOptionPane.showMessageDialog(null,"Please Retry");
}