• Post Reply Bookmark Topic Watch Topic
  • New Topic

Data in table dosen't change after calling fireTableDataChanged ???

 
Mahajan Bhupendra
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi...
i m crating a sample table in which i m having a single cell and single column
here is my code..

now my question is ....
while adding contents of JTable i m adding reference of counter and when i point it to different object i m calling fireTableChanged() as i suppose it should change data...
now i can use setValueAt() method also..
but in my actual problem i m going to add rows dynamically and then sort then on some key....
so setValueAt method will not work since each time a new dynamic row gets added to table it's row no is going to be changed...
please help me...
Thanx in advance..

------------------
Bhupendra Mahajan
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mahajan,
The method fireTableDataChanged only lets table listeners know that something in the table has changed. It doesn't do anything to the table itself!
If you want to set a table value you are going to have to use setValueAt. Add all your values first then reorder the rows. When you add a new row it will always be the last one before you sort.
Regards,
Manfred.
 
Mahajan Bhupendra
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Manfred
i could have done that but as i said i m going to add rows dynamically...
and when to add them is dependent on user...
suppose he adds 10 rows then sorted..
after 2 rows are added then i have to sort them again..
there lies the problem since my thread is having row no (using last row no as u said..)that is not valid now..

------------------
Bhupendra Mahajan
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!