这是一个Swing Java 7渲染错误吗? [英] Is this a Swing Java 7 rendering bug?
问题描述
我制作了一个简单的Swing应用程序。但渲染表现出错误。我做错了什么或者它是一个错误?
I made a simple Swing application. But the rendering behaves buggy. Have I done anything wrong or is it a bug?
这是一个简单的小型JFrame,带有文本字段,按钮和空列表。如果我首先水平调整窗口大小然后输入文本字段,按钮突然消失。
It's simple a small JFrame with a textfield, button and an empty list. If I first resizes the window horizontally and then type in the textfield, the button suddenly disappear.
这是我的代码:
public class App extends JFrame {
public App() {
JTextField messageFld = new JTextField();
JButton saveBtn = new JButton("Save");
JPanel inputPanel = new JPanel(new BorderLayout());
inputPanel.add(messageFld, BorderLayout.CENTER);
inputPanel.add(saveBtn, BorderLayout.EAST);
JList<Data> list = new JList<Data>();
JPanel panel = new JPanel(new BorderLayout());
panel.add(inputPanel, BorderLayout.NORTH);
panel.add(list, BorderLayout.CENTER);
this.getContentPane().add(panel);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setTitle("Test application");
this.pack();
this.setVisible(true);
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
new App();
}
});
}
}
以下是一些截图:
-
启动时
< img src =https://i.stack.imgur.com/ecWxG.pngalt =在此处输入图像说明>
水平调整大小后
在文本字段中列出几个字符后
将鼠标移到按钮上
我使用的是Windows 7,Java 1.7.0和Eclipse Indigo SR1。
我使用的是JDK 1.7.0.0,现在已升级到JDK 1.7.0.10,但我仍然遇到同样的问题。
I use Windows 7, Java 1.7.0 and Eclipse Indigo SR1. I used JDK 1.7.0.0 and have now upgraded to JDK 1.7.0.10 but I still have the same problem.
当我打印系统属性时,我得到了结果:
When I print the system properties I get this result:
System.out.println(System.getProperty("java.version"));
System.out.println(System.getProperty("java.runtime.version"));
> 1.7.0_01
> 1.7.0_01-b08
推荐答案
如果出现问题通过您的图形驱动程序,设置下面的系统属性之一可能会有所帮助。不太确定Java 7中是否仍支持道具。
In case the issue is caused by your graphics driver, setting one of the system properties below could help. Not quite sure if the props are still supported in Java 7.
sun.java2d.d3d=false
sun.java2d.ddoffscreen=false
sun.java2d.noddraw=true
这篇关于这是一个Swing Java 7渲染错误吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!