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

Recommended Answers

All 5 Replies

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

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.

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

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

1.) Default
2.) Repainted after each update

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.