开发者

Stop a jframe requesting focus

开发者 https://www.devze.com 2022-12-11 02:44 出处:网络
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 visibil

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?


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消