java yes 或者 no 的对话框

来源:百度知道 编辑:UC知道 时间:2024/06/15 09:59:12
怎么设置一个对话框让用户 点yes或者no, 然后yes然后运行一段code no运行另一段code.
int cont = JOptionPane.showConfirmDialog(null,"Is this customer a special customer?","comment:",JOptionPane.OK_OPTION);
if(cont!=JOptionPane.OK_OPTION)return;
大概是用这个吧 我主要是不知道怎么让 no运行另一段 这个点no 就直接退出拉

int cont = JOptionPane.showConfirmDialog(null,"Is this customer a special customer?","comment:",JOptionPane.OK_OPTION);
if(cont!=JOptionPane.OK_OPTION){
System.out.println("cancel");
}
else{
System.out.println("ok");
}

if(cont=JOptionPane.OK_OPTION){
do something
}else{
do something
}