我选择了两个下拉菜单后,我希望根据所选内容弹出另一个框以显示信息。当我尝试使用if语句并按下okay按钮时,它会继续到下一行。我从showmessagedialog开始,但我想在一些下拉选项中显示警告。它不工作。我还需要能够回到主菜单,以便他们可以做出不同的选择。什么我现在有如何从选择下拉菜单中选择if语句
例如:
int x = JOptionPane.showOptionDialog(null, "Zookeepers would you like to view animal activities or monitor habitats?",
"Welcome to the Brooklyn Zoo!", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, icon, options, options[0]);
System.out.println(x);
if(x==0){
String[] choices = {"Lions","Tigers","Bears","Giraffes",};
String input = (String) JOptionPane.showInputDialog(null,"Select Animal:","Zoo Animals",
JOptionPane.QUESTION_MESSAGE,null,choices,choices[1]);
if (choices.equals("Lions"));
String [] button = {"OK","Cancel","Warning"};
JOptionPane.showOptionDialog(null, "\"Animal: Lion\\nName: Leo\\nAge: 5 \\nFeeding Schedule: Twice daily\\n\\nALERT: Cut on left front paw",
"Animal",JOptionPane.YES_NO_CANCEL_OPTION,JOptionPane.WARNING_MESSAGE, options, options [0]);
1)为了更快地获得更好的帮助,请发布[MCVE]或[简短,独立,正确的示例](http://www.sscce.org/)。 2)使用合乎逻辑的一致形式缩进代码行和块。缩进旨在使代码的流程更易于遵循! –