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.
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. 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:
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? It should work! Be wary, however, when usingSystemColor… it is a relic from a time when Motif and Windows 95-98 UI were predominantly used. More often than not, it will be utterly inadequate for dealing with modern UIs.