使用 4Gb RAM 和 IBM Java 1.5 时按钮文本消失

发布于 2024-07-14 14:54:31 字数 1035 浏览 5 评论 0原文

我们在开发者网站上发生了一个非常奇怪的错误,我们无法自己复制该错误。

波兰的一位开发人员最近将其 Windows XP Service Pack 3 计算机升级至 4Gb RAM 当他这样做时,他开始在使用 IBM JDK 1.5 的 java 程序中遇到图形错误 此错误仅出现在 IBM JDK 1.5 中,不会出现在任何其他版本中。

当您在窗体上创建按钮或控件并将鼠标移到其上时,问题就会显现出来。

我们有一个测试程序

import java.awt.FlowLayout;

import javax.swing.JButton;
import javax.swing.JFrame;

public class GraphicTest {
    public static void main(String args[]) {
        JFrame frame = new JFrame("GraphicTest");
        frame.getContentPane().setLayout(new FlowLayout());
        frame.setSize(200, 200);
        JButton button = new JButton("Test button");
        button.setVisible(true);
        frame.getContentPane().add(button);
        frame.setVisible(true);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
}

可以立即显示问题。

然而,当我将相同的 Windows 版本升级到 4Gb RAM 时,我自己的机器上并没有出现这个问题。

还有其他人见过这样的问题吗?

为了澄清这一点,这个问题只发生在 IBM JDK 1.5 上,并且只有当我们有 4Gb 的 RAM 时才会发生。 在任何其他版本的 JDK 上都不会发生这种情况,如果我们将内存量减少到 3 GB,问题就会消失。

We have a very strange error occurring at a developer site which we are unable to replicate ourselves.

A developer in Poland has recently upgraded his Windows XP Service Pack 3 machine to 4Gb of Ram
When he did so he started experiencing graphical errors in java programs using IBM JDK 1.5
This errors only occur in IBM JDK 1.5 and not in any other version.

The problem manifests itself when you create a button or control on a form and move the mouse over it.

We have a test program

import java.awt.FlowLayout;

import javax.swing.JButton;
import javax.swing.JFrame;

public class GraphicTest {
    public static void main(String args[]) {
        JFrame frame = new JFrame("GraphicTest");
        frame.getContentPane().setLayout(new FlowLayout());
        frame.setSize(200, 200);
        JButton button = new JButton("Test button");
        button.setVisible(true);
        frame.getContentPane().add(button);
        frame.setVisible(true);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
}

which shows the problem straight away.

However the problem doesn't arise on my own machine when I upgrade the same windows version to 4Gb of Ram.

Has anyone else ever seen an issue like this?

Just to clarify this a bit, this issue only happens with IBM JDK 1.5 and only happens when we have 4Gb of Ram. It doesn't happen on any other version of the JDKs and if we reduce the amount of memory to 3 Gb the problem disappears.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

月下伊人醉 2024-07-21 14:54:32

尝试减少 Windows 图形驱动程序中的硬件优化(可通过扩展显示控制面板访问)。 如果有问题的机器有一个使用部分主内存的板载图形适配器,那么升级 RAM 可能会暴露驱动程序中的问题(或者 RAM 甚至可能有故障)。

Try reducing the hardware optimization in Windows' graphics drivers (accessible through the extended display control panel). If the machine in question has an onboard graphics adapter that uses a part of the main memory, then upgrading RAM might expose problems in the driver (or the RAM may even be faulty).

做个少女永远怀春 2024-07-21 14:54:32

首先要说的显而易见的事情是:将 Swing 组件的使用限制在 AWT 事件调度线程 (EDT) 中。

public class GraphicTest {
    public static void main(final String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                runEDT();
            }
        });
    }
    private static void runEDT() {
        assert java.awt.EventQueue.isDispatchThread();
        JFrame frame = new JFrame("GraphicTest");
        ...

我不知道为什么内存大小很重要。 也许它会以某种方式影响时间。 也许 JVM 决定它在服务器级机器上运行,并以更积极的优化来运行。

The first obvious thing to always say is: Confine usage of Swing components to the AWT Event Dispatch Thread (EDT).

public class GraphicTest {
    public static void main(final String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                runEDT();
            }
        });
    }
    private static void runEDT() {
        assert java.awt.EventQueue.isDispatchThread();
        JFrame frame = new JFrame("GraphicTest");
        ...

I don't know why memory size would be important. Perhaps it affects the timings in someway. Perhaps the JVM decides it is running on a server-class machine and runs with more aggressive optimisation.

滥情空心 2024-07-21 14:54:32

只是为了排除硬件故障假设:让开发人员测试他的 RAM。 Memtest86 会执行此操作。

Just to rule out the hardware failure hypothesis: have the developer test his RAM. Memtest86 will do this.

谜兔 2024-07-21 14:54:32

我在具有 3.24 G 内存的 IBM 机器上遇到了完全相同的情况:所有 swing 应用程序都会显示 - 但文本(在菜单、表单、按钮上 - 似乎无处不在)是空白的。

同样的 swing 程序在 Sun JDK 上运行没有问题。

我将硬件加速从“完全”降低到“无”(在即插即用显示器设置中将显示中的“高级”关闭) - 使用 Intel(r) 82865G 显卡。

现在 Swing 应用程序看起来工作得很好。

好地方...

I had exactly the same thing on an IBM box with 3.24 G of memory: All swing apps would display - but the text (on menus, forms, buttons - everywhere it seems) were blank.

The same swing program running on Sun JDK worked no problem.

I reduced the Hardware Acceleration from 'Full' to 'None' ( on the Plug and Play Monitor settings off 'advanced' in display) - using an Intel(r) 82865G graphics card.

Now swing apps work just fine it seems.

Good spot...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文