简体   繁体   中英

Swing GUI looks different under root user vs. non-root user

I have a Swing GUI that I developed Netbeans Matisse 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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