JTable - help

J

JacQ_21

Hi

I have a problem with JTable - i would like to reedit whole data like
this was on the beggining with default constructor like : JTable
table =new JTable(matrix1,matrix2);

When program runs i like to use different kind of data in this same
table( without erasing it ) - how to change it ?
Thank you very much
Sorry for my English - Poland
All the best
 
V

VisionSet

JacQ_21 said:
Hi

I have a problem with JTable - i would like to reedit whole data like
this was on the beggining with default constructor like : JTable
table =new JTable(matrix1,matrix2);

When program runs i like to use different kind of data in this same
table( without erasing it ) - how to change it ?
Thank you very much
Sorry for my English - Poland
All the best

If I understand you you wish to make updates to the tables data and these be
reflected in the JTable automatically.
To achieve this painlessly a good approach is to create a class that extends
AbstractTableModel and use this to create your JTable in JTables
constructor. All model updates will then fire JTables internal listener and
make the updates automatic.
 
A

andreas kinell

JacQ_21 said:
Hi

I have a problem with JTable - i would like to reedit whole data like
this was on the beggining with default constructor like : JTable
table =new JTable(matrix1,matrix2);

When program runs i like to use different kind of data in this same
table( without erasing it ) - how to change it ?
Thank you very much
Sorry for my English - Poland
All the best

Try writing your own custom TableModel.
Then you could write a method called setValues(Matrix m1, Matrix m2)
which sets the matrices for you.

To detect changes to the model and update the JTable, use a
TableModelListener.

http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#data

HTH, andreas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,143
Latest member
DewittMill
Top