Button text disappearing with 4Gb Ram and IBM Java 1.5

别说谁变了你拦得住时间么 提交于 2019-12-11 10:14:50

问题


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.


回答1:


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).




回答2:


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.




回答3:


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




回答4:


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...



来源:https://stackoverflow.com/questions/591291/button-text-disappearing-with-4gb-ram-and-ibm-java-1-5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!