Link to home
Start Free TrialLog in
Avatar of Cyart
CyartFlag for United Kingdom of Great Britain and Northern Ireland

asked on

JTable with Arrays

I am after Jtable code that will display the rows and columns of a 2d array called returned array. Can anyone help? I am currently using a for loop within main to populate a variable with the values from the array, which is then displayed via a dialog box.

Cheers

ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Cyart

ASKER

can you explain what a vector is cheers?
A Vector class is a (growable) array of objects.
Avatar of Cyart

ASKER

Ok how do I display the table
add it to your component hierarchy.
eg. to add it to your dialog you could use:

dialog.getContentPane().add(table);
Avatar of Naeemg
Naeemg

use JScrollPane and add ur JTable to it

    jspTableScroller.getViewport().add(jtData, null);


Naeem Shehzad Ghuman
I will post a code soon.
create a model class extending AbstractTableModel,

place your vectors in there and fill in the code for the getElementAt(int row, int col)

then make your jtable and pass it the new class as its model,

when you call fireStateDataChanged(); in the model this will fill the data for you.