geronimo2
asked on
How can I add rows using an AbstractTableModel
Using Swing jdk1.2
How can I add a row like you would with DefaultTableModel when I am using the
AbstractTabeleModel
I have created aTwo Dimensional array to store the row and column data
but i need to add a few more rows after the table had been constructed
With the DefaultTableModel you can just create a one dim array for the row data and add it to the model.
Basically so I need my Two dim Array to expand
but i havent a clue where to go now
Any help greatly appreciated
Regards Dave
How can I add a row like you would with DefaultTableModel when I am using the
AbstractTabeleModel
I have created aTwo Dimensional array to store the row and column data
but i need to add a few more rows after the table had been constructed
With the DefaultTableModel you can just create a one dim array for the row data and add it to the model.
Basically so I need my Two dim Array to expand
but i havent a clue where to go now
Any help greatly appreciated
Regards Dave
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Which means, don't use default table model but implement your own. It is easy and there lots of examples on the sun site.
Nik
Nik
ASKER
Note Sorry about delay in responding as I have Limited Internet access here in college.
:) fmaritato
Thanks fmaritato I sorted it out by using DefaultTableModel.
Initially I had implemented by own AbstractTableModel similiar to the one you had outlined above but I had problems with rendering the cells which I have now sorted out.
It was your suggestion about using Vectors etc which helped me.Thanks alot
Regards Dave.
:)kylar
Thanks for suggestion there is a seperate 50 points for you to claim also.
Sound lads Thanks alot for the help
Regards Dave
:) fmaritato
Thanks fmaritato I sorted it out by using DefaultTableModel.
Initially I had implemented by own AbstractTableModel similiar to the one you had outlined above but I had problems with rendering the cells which I have now sorted out.
It was your suggestion about using Vectors etc which helped me.Thanks alot
Regards Dave.
:)kylar
Thanks for suggestion there is a seperate 50 points for you to claim also.
Sound lads Thanks alot for the help
Regards Dave
ASKER
Note Sorry about delay in responding as I have Limited Internet access here in college.
:) fmaritato
Thanks fmaritato I sorted it out by using DefaultTableModel.
Initially I had implemented by own AbstractTableModel similiar to the one you had outlined above but I had problems with rendering the cells which I have now sorted out.
It was your suggestion about using Vectors etc which helped me.Thanks alot
Regards Dave.
:)kylar
Thanks for suggestion there is a seperate 50 points for you to claim also.
Sound lads Thanks alot for the help
Regards Dave
:) fmaritato
Thanks fmaritato I sorted it out by using DefaultTableModel.
Initially I had implemented by own AbstractTableModel similiar to the one you had outlined above but I had problems with rendering the cells which I have now sorted out.
It was your suggestion about using Vectors etc which helped me.Thanks alot
Regards Dave.
:)kylar
Thanks for suggestion there is a seperate 50 points for you to claim also.
Sound lads Thanks alot for the help
Regards Dave
public class tableManipulator{
public tableManipulator(){
DefaultTableModel myModel = new DefaultTableModel();
//assume there is data in the table model
doTableRowAdd(myModel);
}
public void doTableRowAdd(AbstractTabl
//now here you are getting an 'Abstract' table model, but it's really
//a concrete class (DefaultTableModel). so what we do is something like this:
Vector newRowData = new Vector();
//assume we add data to this vector;
//now we cast the abstract to a default, since we know what it is really:
DefaultTableModel dtm = (DefaultTableModel)abstrac
//then we add to it
dtm.addRow(newRowData);
}
}
}
If that's not what you want, I'm sorry :) post your code and we'll see what we can do