Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Printing 2d Array Into TextArea Java Swing

843785Jul 16 2008 — edited Jul 16 2008
Hi there,

Does anyone know how to print a 2D array into a JTextArea in Java swing ?

Here is my code.. where i print my array .. and i tried to set the text into the NewDataText area but unfortunately it prints only the last element of my array. I tried to use table as well but the array is big enough and i get an exception ...(code for table too big). Any ideas?
I        for (int i = 0; i <SomNewArray.length; i++) {
            for (int j = 0; j < SomNewArray.length; j++) {
System.out.print(+SomNewArray[i][j]+",");
DataTool.NewDataText.setText(String.valueOf(SomNewArray[i][j]))
}
System.out.println("");
}
Thanks                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 13 2008
Added on Jul 16 2008
2 comments
1,569 views