File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JList not refreshing ?issue?

 
Werner Fletcher
Ranch Hand
Posts: 34
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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?
 
Maneesh Godbole
Saloon Keeper
Posts: 10971
11
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Post your SSCCE code which demonstrates the problem. Difficult to help you out with just a description
 
Darryl Burke
Bartender
Posts: 5115
11
Java Netbeans IDE Opera
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The most likely cause is that you've ignored Swing's single threaded rule. <-- search the net
 
Paul Clapham
Sheriff
Pie
Posts: 20164
24
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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: 5115
11
Java Netbeans IDE Opera
  • 1
  • Mark post as helpful
  • send pies
  • 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: 5115
11
Java Netbeans IDE Opera
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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: 5115
11
Java Netbeans IDE Opera
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We're still waiting for that SSCCE
 
Werner Fletcher
Ranch Hand
Posts: 34
  • 0
  • Mark post as helpful
  • send pies
  • 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: 5115
11
Java Netbeans IDE Opera
  • 1
  • Mark post as helpful
  • send pies
  • 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.
 
Tarun Bolla
Ranch Hand
Posts: 89
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is working....Perhaps its your code that does something wrong....

 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic