Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JLists dont refresh  RSS feed

 
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: 9425
12
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!