2016-04-05 22 views
0

私は3を作ろうとしていますJOptionPane。それぞれは何らかのデータの配列を表示する必要があります。別のJOptionPaneで別の配列を表示する方法

firstDataArray

の20情報を表示しなければならない最初の場合にのみ、私は新しい JOptionPaneは、それがsecondDataArrayなどの情報を表示する必要がありますポップアップ表示したいキャンセルにユーザーがクリック...

問題I最初JOptionPaneにキャンセルのユーザーのクリック、セカンドJOptionPaneはfirstDataArrayとsecondDataArrayの全ての情報を表示しているとき、キャンセル時に「Mの対面は同じ

(I 2は異なる配列リストで JOptionPaneを分離したい)

です2番目のJOptionPaneの底、3番目のJoptionPaneは3つのデータのすべての情報を表示します。

私は間違っていますか?

多くの感謝、

ベース

 String[] firstDataArray= new String[20]; 
      String[] secondDataArray= new String[20]; 
      String[] thirdDataArray= new String[20]; 

      firstDataArray= ClassA.getFirstData(); 
      secondDataArray= ClassA.getSecondData(); 
      thirdDataArray= ClassA.getThirdData(); 

      StringBuilder textRegion = new StringBuilder(); 

      String txt = JOptionPane.showInputDialog(null, 
        textRegion.append(Arrays.toString(firstDataArray).replace("[", "").replace("]", "").replace(",", "")).append('\n'), "Choose Option)", 
        JOptionPane.PLAIN_MESSAGE); 
//If the user click cancel , show the other array in a new JoptionPane 
      if (txt == null) { 

       txt = JOptionPane.showInputDialog(null, 
         textRegion.append(Arrays.toString(secondDataArray).replace("[", "").replace("]", "").replace(",", "")).append('\n'), "Choisir municipalite (Chose option)", 
         JOptionPane.PLAIN_MESSAGE); 


//If the user click cancel again , show the other array in a third JoptionPane 
        if (txt == null) { 

        txt = JOptionPane.showInputDialog(null, 
          textRegion.append(Arrays.toString(thirdDataArray).replace("[", "").replace("]", "").replace(",", "")).append('\n'), "Chose Option)", 
          JOptionPane.PLAIN_MESSAGE); 
        if (txt == null) { 

        } else { 
         setNomMunicipalite(txt); 
        } 

       } else { 
        setNomMunicipalite(txt); 
       } 
      } else { 
       setNomMunicipalite(txt); 
      } 

答えて

2

あなたはいつも同じStringBuilderに各配列を付加しています。

は、私ははいそれは私のミスのおかげだった.....という逃したか、各JOptionPane

 StringBuilder textRegion = new StringBuilder(); 

     String txt = JOptionPane.showInputDialog(null, 
       textRegion.append(Arrays.toString(firstDataArray).replace("[", "").replace("]", "").replace(",", "")).append('\n'), "Choose Option)", 
       JOptionPane.PLAIN_MESSAGE); 
     //If the user click cancel , show the other array in a new JoptionPane 
     if (txt == null) { 
      textRegion = new StringBuilder(); // <--- 
      txt = JOptionPane.showInputDialog(null, 
        textRegion.append(Arrays.toString(secondDataArray).replace("[", "").replace("]", "").replace(",", "")).append('\n'), "Choisir municipalite (Chose option)", 
        JOptionPane.PLAIN_MESSAGE); 


       //If the user click cancel again , show the other array in a third JoptionPane 
       if (txt == null) { 
       textRegion = new StringBuilder(); // <--- 

       txt = JOptionPane.showInputDialog(null, 
         textRegion.append(Arrays.toString(thirdDataArray).replace("[", "").replace("]", "").replace(",", "")).append('\n'), "Chose Option)", 
         JOptionPane.PLAIN_MESSAGE); 
       if (txt == null) { 

       } else { 
        setNomMunicipalite(txt); 
       } 

      } else { 
       setNomMunicipalite(txt); 
      } 
     } else { 
      setNomMunicipalite(txt); 
     } 
+0

ohhhhのための新しいものを使用してください! – napi15

+0

@ napi15喜んで助けてください。 :-) – RubioRic

関連する問題