• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How can I make JList update when ListModel changed?

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi, I have a JList and I use a DefaultListModel to store the list entries.
I have a button on that panel. When the button is clicked, I remove all the entries from DefaultListModel and add all entries back from a sql query result.(I have to do it that way)

My problem is, after I did the operation on my DefaultListModel above, the content of JList doesn't change(the database has been changed), however, sometimes it works.(some times not) I'm wondering that do I need to call a sort of refresh method on JList after I make changes on the ListModel.

If someone can help, that will be great.
 
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Ren Shao
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi, Craig, the code you show me is actually what I've done. It didn't work properly as the JList won't refresh every time I click the button.(Sometimes it does but most time it doesn't, do you know why?
[ September 22, 2004: Message edited by: Ren Shao ]
 
Ren Shao
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know what's wrong, thanks!!
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ren Shao:
I know what's wrong, thanks!!



Care to share? This board is all about helping each other out. You could save someone hours of debugging just by explaining what your solution is.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic