views:

135

answers:

2

I have a small application that updates the contents of a JFrame very quickly (many times per second) and on each update (I remove a component and then add a new one, then set visibility true again) the JFrame flashes on the Taskbar (WinXp) to request focus. It's very annoying and I'm sure it can be disabled. I just cant find out where.

Any ideas?

+3  A: 

Am I understanding you correctly

You do something like

frame.remove(cold);
frame.add(cnew);
frame.setVisible(false);
frame.setVisible(true);

Instead of doing this try using

frame.remove(cold);
frame.add(cnew);
frame.validate()
jitter
My swing is rusty, but shouldn't that be invalidate() ?
Bart van Heukelom
Care to explain why? Only subcomponents of the JFrame have changed. Why should I mark the JFrame itself and all of its parents as invalid?
jitter
+2  A: 

I remove a component and then add a new one,

The better solution would be to simply update the existing component. Swing components are designed to repaint themselfs when there properties and data are changed.

camickr