• 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

JList not refreshing ?issue?

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey all,

I made a chat program with a JList which displays the users online. Sometimes I have this issue where the list just goes blank and I have to quit and restart the program in order for it to work again properly. Can someone PLEASE tell me what is up with this listmodel? Is there any way to fix this, because when some users join they just see a blank list and assume that nobody is online. It's freaking me out.

Thanks!
 
Werner Fletcher
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I stumbled upon this post: http://lists.apple.com/archives/student-dev/2004/Jun/msg00005.html

Makes sense, but how would I call those methods?
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Post your SSCCE code which demonstrates the problem. Difficult to help you out with just a description
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The most likely cause is that you've ignored Swing's single threaded rule. <-- search the net
 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Or there could be code which clears the data from the list model. That would explain why it goes blank.
 
Werner Fletcher
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

The most likely cause is that you've ignored Swing's single threaded rule. <-- search the net


Each client application has their own list and data just gets added or removed from the model, I'm not using any threads on the list or listmodel.

Or there could be code which clears the data from the list model. That would explain why it goes blank.


I've checked this, I don't use any code to clear the list completely, just addElement/removeElement/set.

Another weird thing - Check this code:

When I do that, the list updates fine, BUT if I do this:

The freaking list stays blank! HELP me please!! What am I doing wrong??
 
Darryl Burke
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Werner Fletcher wrote:Another weird thing - Check this code:

When I do that, the list updates fine, BUT if I do this:

The freaking list stays blank! HELP me please!! What am I doing wrong??



SSCCE or it didn't happen.
 
Darryl Burke
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Werner Fletcher wrote:

The most likely cause is that you've ignored Swing's single threaded rule. <-- search the net


Each client application has their own list and data just gets added or removed from the model, I'm not using any threads on the list or listmodel.



Every Swing application has at least two threads -- the main thread and the EDT. Are you invoking all methods of Swing components only on the EDT?
 
Werner Fletcher
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Darryl Burke wrote:Every Swing application has at least two threads -- the main thread and the EDT. Are you invoking all methods of Swing components only on the EDT?



I'm not too familiar with what you are asking. Will it help if I put the code that is supposed to update the list in a Swingworker?
 
Darryl Burke
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We're still waiting for that SSCCE
 
Werner Fletcher
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Darryl Burke wrote:We're still waiting for that SSCCE


I know lol, it's really difficult to do, the app is kindof intense. I'll try my best
 
Darryl Burke
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Don't try to cut down your existing app to make an SSCCE. Start small, and add just enough functionality to reproduce the problem.
 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is working....Perhaps its your code that does something wrong....

 
reply
    Bookmark Topic Watch Topic
  • New Topic