aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes JList not refreshing ?issue? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JList not refreshing ?issue?" Watch "JList not refreshing ?issue?" New topic
Author

JList not refreshing ?issue?

Werner Fletcher
Ranch Hand

Joined: Apr 19, 2011
Posts: 34
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

Joined: Apr 19, 2011
Posts: 34
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

Joined: Jul 26, 2007
Posts: 10255
    
    8

Post your SSCCE code which demonstrates the problem. Difficult to help you out with just a description


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4529
    
    5

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


luck, db
There are no new questions, but there may be new answers.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

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

Joined: Apr 19, 2011
Posts: 34
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

Joined: May 03, 2008
Posts: 4529
    
    5

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

Joined: May 03, 2008
Posts: 4529
    
    5

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

Joined: Apr 19, 2011
Posts: 34
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

Joined: May 03, 2008
Posts: 4529
    
    5

We're still waiting for that SSCCE
Werner Fletcher
Ranch Hand

Joined: Apr 19, 2011
Posts: 34
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

Joined: May 03, 2008
Posts: 4529
    
    5

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

Joined: Jun 20, 2011
Posts: 89
This is working....Perhaps its your code that does something wrong....

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JList not refreshing ?issue?