【发布时间】:2015-01-24 21:36:28
【问题描述】:
所以我试图在我的程序中运行一个确认对话框,询问用户是否想使用 import javax.swing.JOptionPane 升级他们的会员资格
但是,当我去执行时,程序总是恢复到好像我单击了“是”。请帮忙?
int option =
JOptionPane.showConfirmDialog(null,
"Would you like to become a member for $4.95?",
"Upgrade Membership",
JOptionPane.YES_NO_CANCEL_OPTION);
if (answer == JOptionPane.YES_OPTION)
{
JOptionPane.showMessageDialog(null, "Thank you. Your membership fee will be"
+ " added to your receipt.");
dFee = 4.95;
sMember = "Premium";
}
if (answer == JOptionPane.NO_OPTION)
{
JOptionPane.showMessageDialog(null, "Thank you for your consideration.");
sMember = "Regular";
}
if (answer == JOptionPane.CANCEL_OPTION)
{
JOptionPane.showMessageDialog(null, "You may purchase a membership in the"
+ " future.");
sMember = "Regular";
}
【问题讨论】:
标签: java swing confirmation