954,536 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Starnge swing problem

Hello guys,

I don't really need a solution, just answer - some Swing insight. So I have a panel, and a list on it. The list is populated with strings. The problem is the following: If I add the list elements too fast, I end up with different kinds of strange windows. However, after introducing a sleep(100), or another function call, it surprisingly works fine. I didn't believe this was the problem, so I added and removed the sleep several times. It solved the glitch 10/10.

How? Why? Ideas and guessings are welcome as well.

Thanks in advance,
Chaster

Chaster
Junior Poster in Training
68 posts since Jun 2007
Reputation Points: 12
Solved Threads: 3
 

Swing lib use threading to Draw as you may knew , can you please post the code .

msi_333
Newbie Poster
22 posts since Jun 2007
Reputation Points: 10
Solved Threads: 4
 
Swing lib use threading to Draw as you may knew , can you please post the code .

It's kind of confidential. I just hoped someone came across the same issue ;). Actually it's nothing special about the code. It's not multi-threaded, I just add several entries to the list.

Chaster
Junior Poster in Training
68 posts since Jun 2007
Reputation Points: 12
Solved Threads: 3
 

1.What about model of JList?
2.Forced repaint() method?

quuba
Posting Pro
573 posts since Nov 2008
Reputation Points: 123
Solved Threads: 106
 
1.What about model of JList? 2.Forced repaint() method?

1.) Default
2.) Repainted after each update

Chaster
Junior Poster in Training
68 posts since Jun 2007
Reputation Points: 12
Solved Threads: 3
 

Your code looks like this?
JList list;
/////
DefaultListModel model = new DefaultListModel();
list = new JList(model) ;

quuba
Posting Pro
573 posts since Nov 2008
Reputation Points: 123
Solved Threads: 106
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You