我正在使用 if else 并突然写下一些代码, 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");}
1 回答
陪伴而非守候
TA贡献1757条经验 获得超8个赞
检查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");
}
添加回答
举报
0/150
提交
取消