Cyart
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
Cheers
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
A Vector class is a (growable) array of objects.
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().ad d(table);
eg. to add it to your dialog you could use:
dialog.getContentPane().ad
use JScrollPane and add ur JTable to it
jspTableScroller.getViewpo rt().add(j tData, null);
Naeem Shehzad Ghuman
jspTableScroller.getViewpo
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.
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.
ASKER