• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

simple question on JTable

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi i am using TableModel and assigning object of array. everything is fine. Now when i want to update my table model with new data i issue setVectorData() method with appropriate parameters. Data get's refreshed but the number of rows it previousely had remains. How can i make it so the number of rows will be same as data held.
thanks.
 
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You must be doing something else wrong. When you call setDataVector( Vector, Object[]), it will automatically update the rowCount of the model.
SAF
 
Ruslan Ivanov
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hmm, it didn't do it for me. I just see new data with old number of rows.
 
SAFROLE YUTANI
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Where are you getting the row count from? You should be calling DefaultTableModel.getRowCount()
SAF
 
Ruslan Ivanov
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
why would i need to call getRowCount method for ? And where would i assign it. I think model calls it itself or you can overide it when you implement it for some other logic.In my case i would think that getRowCount should be called by setDataVector to allocate number of rows to build for a table. But it doesn't do it.
 
SAFROLE YUTANI
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm saying that if you call DefaultTableModel.getRowCount() after you call setDataVector(), the number returned should be equal to the size of the Vector.
SAF
 
Ruslan Ivanov
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry i found my error, in one of my Object[] arrays i didn't trim number of elements. So that was the reason. Thanks for the help. It now displays correctly everything.
 
Clowns were never meant to be THAT big! We must destroy it with this tiny ad:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic