• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Updating JTable data sources

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is my first post - if this question is better suited to the intermediate forum, I apologize and will take it there.
I'm having difficulty getting my table to refresh its data model and itself (appearance wise).
I'm using a DefaultTableModel which is constructed with 2 Vectors.
1 is the data Vector, the other for the column headings.
To begin, I start my application with an empty data Vector, so the
table is displayed as empty - fine no problems.
Next I have a button which adds an entry to the data Vector, and also
generates an event for the table.
To construct the event (TableModelEvent), I pass it my table model.
Then I have used both newRowsAdded() and newDataAvailable() to deliver
the event.
I do have a TableModelListener, and the gist of what is does is an
addRow() where I pass it the new row data.
Here's the problematic behaviour - When I use the GUI to update the
table, it enters the 1 row of data over and over again (maybe 32k times).
I would appreciate any insights, or feedback. Thanks.
 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have created a loop. Post some code, please.
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to the Swing / JFC / AWT forum...
 
Aran Winters
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's my problem code:

So that's it (of course I've only posted some blocks).
I have since found a workaround by putting the addRow()
call into the JButton listener, but I was hoping someone
might explain how I had created a loop through this code.
Thanks.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!