简体   繁体   English

这是一个Swing Java 7渲染错误吗?

[英]Is this a Swing Java 7 rendering bug?

I made a simple Swing application. 我做了一个简单的Swing应用程序。 But the rendering behaves buggy. 但渲染表现出错误。 Have I done anything wrong or is it a bug? 我做错了什么或者它是一个错误?

It's simple a small JFrame with a textfield, button and an empty list. 这是一个简单的小型JFrame,带有文本字段,按钮和空列表。 If I first resizes the window horizontally and then type in the textfield, the button suddenly disappear. 如果我首先水平调整窗口大小然后键入文本字段,按钮会突然消失。

Here is my code: 这是我的代码:

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

}

Here are a few screenshots: 以下是一些截图:

  1. At start up 在启动时

    在此输入图像描述

  2. After horizontal resize 水平调整大小后

    在此输入图像描述

  3. After typig a few charachers in the textfield 在文本字段中列出了几个字符

    在此输入图像描述

  4. After moving the mouse over the button 将鼠标移到按钮上后

    在此输入图像描述

I use Windows 7, Java 1.7.0 and Eclipse Indigo SR1. 我使用Windows 7,Java 1.7.0和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. 我使用的是JDK 1.7.0.0,现在升级到JDK 1.7.0.10,但我仍然遇到同样的问题。

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

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. 不太确定Java 7中是否仍支持道具。

sun.java2d.d3d=false
sun.java2d.ddoffscreen=false
sun.java2d.noddraw=true

I am using eclipse helios service release 2, and java 1.6 and I am not getting that bug; 我正在使用eclipse helios服务版本2,而java 1.6和我没有得到那个bug; it works fine for me. 这对我来说可以。 However it wont let me add parameters to JList...that may be because I'm using an older version of java...so basically with my setup and no parameters for JList it works...I'm not sure if this will help you, but those are my observations 但是它不会让我向JList添加参数...这可能是因为我使用的是旧版本的java ...所以基本上我的设置并没有JList的参数它工作...我不知道这是否会帮助你,但这些是我的观察

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM