Swing 渲染在 JDK 1.8 中出现损坏,在 JDK 1.7 中更正 [英] Swing rendering appears broken in JDK 1.8, correct in JDK 1.7

查看:58
本文介绍了Swing 渲染在 JDK 1.8 中出现损坏,在 JDK 1.7 中更正的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了 IntelliJ IDEA (13.1.1 #IC-135.480) 和 JDK 1.8.0 (x64) 并且我用 GUI 表单设计器生成了一些 GUI.

I have installed IntelliJ IDEA (13.1.1 #IC-135.480) and JDK 1.8.0 (x64) and I generated some GUI with the GUI Form designer.

然后我运行了代码并意识到有些不对劲.

Then I ran the code and realized that something is not alright.

这是我的 GUI 的屏幕截图:

Here is a Screenshot of my GUI:

字体的渲染似乎不太好.此外,当我将鼠标移到 Button 上时,它的文本会丢失.

The rendering of the Font seems to be not OK. Additionally the Button looses its Text, when I move my mouse over it.

所以我安装了 JDK 1.7.0_40 (x64),重新编译项目并再次运行.

So I installed JDK 1.7.0_40 (x64), recompiled the Project and ran it again.

当我使用 JDK 1.7 时,会出现以下表单:

The following Form appears, when i use JDK 1.7:

渲染似乎没问题,按钮也正常.

The Rendering seems to be OK and the Button is also OK.

所以我安装了最新的显卡和芯片组驱动程序等等,但问题仍然存在.您在 Java Swing UI 方面遇到过这样的问题吗?你能帮我解决我的问题吗?任何帮助将不胜感激.

So I installed the newest Graphics and Chipset drivers and much more, but the problem still exists. Have you ever had such problems with Java Swing UIs? Could you help me to fix my problems? Any help would be greatly appreciated.

我创建了一个只有 1 个 JTextArea 和 1 个 JButton 的小项目,但我遇到了相同的渲染问题.

I created a small Project with only 1 JTextArea and 1 JButton and i have the same rendering problems.

根据 Andrew Thompson 的说法,我更改了 setSize() 并从 EDT 开始.下面的例子:

According to Andrew Thompson i changed the setSize() and I start from EDT. The Example below:

package at.maeh.java.client.simpleTextClient;

import javax.swing.*;
import java.awt.*;

public class SimpleClient extends JFrame {
    private JPanel panel1;
    private JTextArea textArea1 = new JTextArea();
    private JButton button1 = new JButton();

    public SimpleClient() {
        super("SimpleClient");

        // Panel
        panel1 = new JPanel();
        panel1.setLayout(new FlowLayout());

        // BUtton
        button1.setText("TestButton");

        // TextArea
        textArea1.setColumns(40);
        textArea1.setRows(15);

        // Add Components
        panel1.add(textArea1);
        panel1.add(button1);

        // Add to Frame
        this.getContentPane().add(panel1);

        // pack and set Visible
        pack();
        setVisible(true);

        System.out.println("Constructor EDT: " + SwingUtilities.isEventDispatchThread());
    }

    public static void main(String[] args) {
        SwingUtilities.invokeLater(SimpleClient::new);

        System.out.println("Main EDT: " + SwingUtilities.isEventDispatchThread());
    }
}

结果是一个包含组件的简单 JFrame.

The result is a simple JFrame with the Components in it.

启动后立即截图">

当我写一些文本,或者将鼠标指针移到按钮上时,组件会像这样呈现(文本:testsentence.123;按钮标签:TestButton)

When I write some Text, or moove my mousePointer over the Button the components get rendered like this (Text: testsentence.123; Button-Label: TestButton)

推荐答案

我终于找到了解决我的问题的方法.我不得不将 NVIDIA GeForce 620M 的能量控制设置更改为最高性能.

Finally I found the solution for my problem. I had to change the energy control settings of my NVIDIA GeForce 620M to maximum performance.

这篇关于Swing 渲染在 JDK 1.8 中出现损坏,在 JDK 1.7 中更正的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆