我選擇了兩個下拉菜單後,我希望根據所選內容彈出另一個框以顯示信息。當我嘗試使用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)使用合乎邏輯的一致形式縮進代碼行和塊。縮進旨在使代碼的流程更易於遵循! –