简体   繁体   English

Windows XP中的Java AWT本机框架颜色不正确

[英]Java AWT Native Frame Color incorrect in Windows XP

I'm developing a GUI for a moderately complex application using Java AWT for the GUI and it looks great when I run it in X11 (with any desktop manager) on linux but in Windows XP it looks weird. 我正在使用Java AWT为中等复杂的应用程序开发GUI,当在Linux的X11(带有任何桌面管理器)中运行它时,它看起来很棒,但是在Windows XP中,它看起来很奇怪。

Actually, at first it looks okay but if I need to change the background color of any of the frames, I can't change it back to the correct color afterwards. 实际上,起初看起来还不错,但是如果我需要更改任何框架的背景色,之后便无法将其更改回正确的颜色。 When I try to set the background color back to normal the frames get what looks like solid white backgrounds rather than the beige color that native applications have in XP. 当我尝试将背景色设置为正常时,框架看起来像纯白色背景,而不是XP中本机应用程序具有的米色。 I can't seem to make them look more natural. 我似乎无法使它们看起来更自然。

I've tried: 我试过了:

frame.setBackground(null);

and

frame.setBackground(java.awt.SystemColor.window);

with no success. 没有成功。 Any suggestions would be appreciated. 任何建议,将不胜感激。

Thanks in advance for any help! 在此先感谢您的帮助!

-Jonathan Perry-Houts -乔纳森·佩里·豪特斯

Edit: Here's a quick example to demonstrate what I mean, I would expect this small empty frame to be beige but instead it's white in Windows XP: 编辑:这是一个简单的示例来说明我的意思,我希望这个小的空白框是米色的,但是在Windows XP中它是白色的:

import java.awt.*;

public class HelloWorld {
    public static void main(String[] args) {
        Frame f = new Frame("Hello World");
        f.setPreferredSize(new Dimension(200, 200));
        f.setBackground(SystemColor.window);
        f.pack();
        f.setVisible(true);
    }
}

As stated in my comment ... have you tried SystemColor.control ? 我的评论所述 ...您是否尝试过SystemColor.control It should work! 它应该工作! Be wary, however, when using SystemColor ... it is a relic from a time when Motif and Windows 95-98 UI were predominantly used. 但是请注意,使用SystemColor ……这是主要使用Motif和Windows 95-98 UI时的遗物。 More often than not, it will be utterly inadequate for dealing with modern UIs. 通常,它完全不足以处理现代UI。

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

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