hi,
I have a problem with my JTable it displays the same line at all lignes,my code consists
to use a command that will be run in background (using the command exec.getRuntime ()), and this will return multiple rows for that, I used a variable "i" to initialize lines and the the loop "for" to move forward, but when I compile I get the first value of the result which affects all lines.
the command "cmd" send me more lines, and I want every line result of this request will be assigned to a line of my table, that is why I use the method "StringTokenizer" for separation:
here is my code:

public Object[][] data;
public String  title[] = {"t1","t2","t3","t4","t5"};

 data = new Object[100][5];
             for(int i=0;i<100;i++){   //pour les lignes
//                 for(int j=0;j<5;j++){
             
           
       try{ 
        String 	 cmd = "la commande que je veut que chaque ligne de résultat sera affecté à chaque ligne de mon tableau";                        
        Process p = Runtime.getRuntime().exec(cmd);
        .... //traitemnt de la commande fournie
      }
        String response = build.toString();
         // String delimiter =" : " ;
        //String qz11=response1.substring(35,response1.length()-1);
        //String str[]=response.split(" . ");
         
         StringTokenizer st = new StringTokenizer(response,":"); 
           while (st.hasMoreTokens()) { 
                    data[i][0] =st.nextToken() ;      
       }
        }catch(Exception e){
	e.printStackTrace();}  
        
       jTable1= new JTable(data, title);
        jScrollPane1.setViewportView(jTable1);
                 }
                 
             }

I don't know where is the problem,and thanks for any help,

please read how the JTable works, there is detailed describtions about how to populating data for JTable

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.