Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JLists dont refresh

 
Jamie CB
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a pair of JLists in my program. I have overidden the AbstractListModel so that they are wrapped around a hash table - one displays keys and the other values. If I change something the hash table they deal with it fine, but if I try to add a value they trun white. if I then resize the container they disappear altogether and never come back. Ive tried repaint() and revalidate() after adding the extra element, but with no effect. Im sure the list model is correct - what else can I do?

Jamie
 
Joe Ess
Bartender
Posts: 9362
11
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
repaint() and revalidate() tell the view to draw itself again to apply the layout (respectively). Those methods have nothing to do with synchronizing the view with the model. The view and model are synchronized through a listener-event arrangement where the view registers to receive events from the model when data changes. AbstractListModel manages this relationship and provides convenience methods for firing the events. All you have to do is consult the documentation for AbstractListModel and determine which of the "fire" methods bests suits your situation.
 
Always look on the bright side of life. At least this ad is really tiny:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!