Chilly
Chilly

Reputation: 335

Stop a jframe requesting focus

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?

Upvotes: 0

Views: 1331

Answers (2)

camickr
camickr

Reputation: 324108

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.

Upvotes: 2

jitter
jitter

Reputation: 54605

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()

Upvotes: 4

Related Questions