Swing应用程序无法运行 [英] Swing apps doesn't run

查看:54
本文介绍了Swing应用程序无法运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用秋千时遇到问题.我不知道这是什么原因,但我只是想使用swing创建一个简单的框架应用程序,这给了我很多错误.

I have a problem in using swing. I don't know what is the cause of this but i'm just trying to create a simple frame app using swing at it give me a lot of error.

    import javax.swing.JFrame;
public class StacksGui {
public static void main(String args[]) 
     JFrame frame = new JFrame();
     frame.setVisible(true);
     frame.setSize(100,200);
     frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}


    Exception in thread "main" java.lang.ExceptionInInitializerError
    at javax.swing.JPanel.updateUI(Unknown Source)
    at javax.swing.JPanel.<init>(Unknown Source)
    at javax.swing.JPanel.<init>(Unknown Source)
    at javax.swing.JPanel.<init>(Unknown Source)
    at javax.swing.JRootPane.createGlassPane(Unknown Source)
    at javax.swing.JRootPane.<init>(Unknown Source)
    at javax.swing.JFrame.createRootPane(Unknown Source)
    at javax.swing.JFrame.frameInit(Unknown Source)
    at javax.swing.JFrame.<init>(Unknown Source)
    at StacksGui.main(StacksGui.java:9)
Caused by: java.lang.IllegalArgumentException: 0 incompatible with Text-specific LCD contrast key
    at java.awt.RenderingHints.put(Unknown Source)
    at sun.awt.windows.WDesktopProperties.getDesktopAAHints(Unknown Source)
    at sun.awt.windows.WToolkit.getDesktopAAHints(Unknown Source)
    at sun.awt.SunToolkit.getDesktopFontHints(Unknown Source)
    at sun.awt.windows.WDesktopProperties.getProperties(Unknown Source)
    at sun.awt.windows.WToolkit.updateProperties(Unknown Source)
    at sun.awt.windows.WToolkit.lazilyInitWProps(Unknown Source)
    at sun.awt.windows.WToolkit.lazilyLoadDesktopProperty(Unknown Source)
    at java.awt.Toolkit.getDesktopProperty(Unknown Source)
    at javax.swing.UIManager.<clinit>(Unknown Source)
    ... 10 more

推荐答案

当所有Java Swing应用程序都静默崩溃时,我遇到了问题.尝试从命令行启动后,出现以下异常:

I had problem when all java Swing apps crashed silently. After trying to launch from command line got the following exception:

Caused by: java.lang.IllegalArgumentException: 181193932 incompatible with Text-specific LCD contrast key

JDK-6503988 所述,问题是与 ClearType 注册表设置

As it's said in JDK-6503988, the problem is connected with ClearType registry setting FontSmoothingGamma.

可以通过运行"调整ClearType文本来解决此问题"(通过控制面板( cttune.exe ))或通过

This can be fixed by running "Adjust ClearType text" from Control panel (cttune.exe) or by changing the registry directly:

reg add "HKEY_CURRENT_USER\Control Panel\Desktop" /t REG_DWORD /v FontSmoothingGamma /d 1024 /f

可能需要重新启动才能使更改生效.

A reboot may be needed for changes to take the effect.

另请参阅https://www.rarst.net/software/cleartype-in​​stall4j-java-bug/.

这篇关于Swing应用程序无法运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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