【发布时间】:2021-02-12 14:37:27
【问题描述】:
如果用户在inputDialog上点击了Cancel,如何处理?我已经尝试过以前发布的解决方案,但都没有奏效。
这是我的代码
String bidString = JOptionPane.showInputDialog(null, "Place your bid ", "Bid",
JOptionPane.PLAIN_MESSAGE);
while(bidString.isEmpty())
{
JOptionPane.showMessageDialog(null,"You must enter a value",
"The Numbers Game", JOptionPane.ERROR_MESSAGE);
bidString = JOptionPane.showInputDialog(null, "How much do you wish to bid?", "Initial funds"
,JOptionPane.QUESTION_MESSAGE);
if(bidString != null)
{
return;
}
}
int bid = Integer.parseInt(bidString);
【问题讨论】:
标签: java swing user-interface joptionpane