Swing GUI looks different under root user vs. non-root user
I have a Swing GUI that I developed Netbeans Matis开发者_如何学Gose in Linux. For some odd reason, the look and feel of the application looks different when it's run by root (it looks better, actually).
Is there a reasoning for this? Thanks
Swing is a cross platform GUI. It renders itself by default with a look and feel which most closely resembles the platform it is running on. There are look and feels for GTK, Motif and Windows as well as cross platform themes like Metal & Nimbus.
In Linux it will default to use the GTK theme if you have gtk 2.2 installed. It may be on your system that the GTK theme is different for root than it is for a regular user and your Swing app is reflecting that. Or it may be that it can't detect GTK correctly in root and is defaulting to Motif.
Try logging in as root and see if the desktop theme is the same or different. Try running the app and see if it reflects the desktop theme or is something else entirely.
精彩评论