2016-04-05 5 views
0

Ich versuche, 3 JOptionPane zu machen. Jeder muss ein Array von Daten anzeigen.So zeigen Sie verschiedene Arrays in separaten JOptionPane

Die erste der 20 Informationen von firstDataArray zeigen müssen

Erst wenn der Benutzer klicken Sie auf kündige ich die neue JOptionPane wollen Pop-up muss die Informationen von secondDataArray Anzeige etc ...

Das Problem, das ich sind zugewandt ist, wenn der Benutzer abzubrechen klicken Sie auf den ersten JOptionPane, die Zweiten JOptionPane wird alle Daten des firstDataArray und die secondDataArray Anzeige (ich will 2 JOptionPane mit verschiedener Array-Liste getrennt)

Gleiche, wenn der Aufhebungs unten der zweiten JOptionPane, die dritte JoptionPane zeigt alle Informationen der 3 Daten Array

Was mache ich falsch?

viel Anerkennung,

Bass

 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); 
      } 

Antwort

2

Sie sind immer jedes Array auf den gleichen StringBuilder anhängt.

eine neue Verwendung für jeden 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, wie ich verpasst, dass ..... Ja, dass mein Fehler Dank war! – napi15

+0

@ napi15 Gut zu helfen. :-) – RubioRic

Verwandte Themen