【发布时间】:2014-05-20 16:42:50
【问题描述】:
一切运行完美,但String am1 = (String)JOptionPane.showInputDialog 显示随机默认“-1”。
private void am1ActionPerformed(java.awt.event.ActionEvent evt) {
getinfo();//Set the random question and answer
am1.setEnabled(false);
Object[] options = {"Answer", "Cancel"};
int n = JOptionPane.showOptionDialog(null,
JeopardyGUI.question1_1,//Reference the question set
"",
JOptionPane.YES_NO_OPTION,
JOptionPane.PLAIN_MESSAGE,
null, //do not use a custom Icon
options, //the titles of buttons
options[0]); //default button title
if(n == JOptionPane.YES_OPTION){
String am1 = (String)JOptionPane.showInputDialog("",JOptionPane.PLAIN_MESSAGE);
if(am1.equalsIgnoreCase(JeopardyGUI.answer1_1)){
Jscore += 100;
JOptionPane.showMessageDialog(null, JeopardyGUI.answer1_1 );
}
else if(!am1.equalsIgnoreCase(JeopardyGUI.answer1_1)){
Jscore += -100;
JOptionPane.showMessageDialog(null, JeopardyGUI.answer1_1 );
}
// else
// am1.setEnabled(true);
}
if(n == JOptionPane.NO_OPTION){
//am1.setVisible(false);
am1.setEnabled(true);
}
}
【问题讨论】:
标签: java user-interface joptionpane inputbox