是什么导致Jframe在调整大小时闪烁? [英] What causes the Jframe to flicker while resizing?
本文介绍了是什么导致Jframe在调整大小时闪烁?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
public class AspectRatio extends JFrame implements ComponentListener{
public AspectRatio() {
setSize(100, 100);
setVisible(true);
addComponentListener(this);
}
public static void main(String[] args){
new AspectRatio();
}
@Override
public void componentHidden(ComponentEvent e) {
// TODO Auto-generated method stub
}
@Override
public void componentMoved(ComponentEvent e) {
// TODO Auto-generated method stub
}
@Override
public void componentResized(ComponentEvent e) {
int i = Math.max(getWidth(), getHeight());
setSize(i, i);
}
@Override
public void componentShown(ComponentEvent e) {
// TODO Auto-generated method stub
}
}
这里是您可以复制粘贴的示例.除了我自己,我无法代表任何人说话,但是当我调整大小时,JFrame忽然闪烁.有人知道是什么原因造成的吗?
Here is an example you can copy paste. Im cant speak for anyone but myself, but when i resize, the JFrame flickers wierdly. Does someone know what causing this?
谢谢你.
推荐答案
听起来像是自动刷新/自动重画的问题.拖动JPane时,它会尝试更新其所有组件的布局,从而导致闪烁.该讨论应具有解决方案:如何停止调整Jframe大小时自动重绘()
Sounds like an auto-refresh/auto-repaint issue. As you drag the JPane, it tries to update layout of all of its components, causing a flickering. This discussion should have the solution: How to stop the auto-repaint() when I resize the Jframe
这篇关于是什么导致Jframe在调整大小时闪烁?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文