<Swing Dev> Native look and feel on linux [2]

Philip Race philip.race at oracle.com
Sun May 22 23:16:00 UTC 2016


 >  UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()).
 > In gnome DE this call makes LAF==GTK. In other DE==Metal (LAF depends
 > on openjdk, not distro). Superficially this sounds like since there 
is no gnome desktop,
 > there is no reason to presume GTK is the "system" L&F.

ie system in this case means "desktop evironment", not "OS".

 >  The request is to make hardcoded default LAF==GTK for all Linux 
distributions,

Aside from that being a big change I am not sure it is right as a 
general policy.
Consider that Solaris 10 has CDE/Motif & Gnome. JDK has L&F support for 
both.
Which one is the "system" L&F would depend on the user's choice of desktop.
The same would apply if (theoretically) we had a KDE L&F.

So L&F should not always just be tied to O/S, but for Linux it
just so  happens to be that we only have GTK, and not KDE.

>What I see now is: when I do not hardcode LAF in my java app it looks
>Metal on Windows and GTK on Linux. When I hardcode I see Native LAF on
>Windows and Metal on Linux ¯\_(ツ)_/¯

Hmm. Does not sound right. ie the case of "I do not hardcode ... it 
looks .. GTK on Linux".

If you do absolutely nothing it should be Metal, so what are you in fact 
doing in
the "I did not hard code it" case ?

I don't know what would prevent you from installing the GTK L&F
even if it is not the "system" one.

If for some reason you cannot instantiate the GTK L&F on Linux
it may be you don't have some native libraries installed.


-phil.

On 5/21/16, 10:57 AM, Yan wrote:
> High!
>
> I've conducted talks with Ubuntu devs:
> https://bugs.launchpad.net/ubuntu/+source/openjdk-7/+bug/1581835
>
> Altogether: This behavior exists in latest openjdk. There are two ways
> to set LAF:
> 1) hardcoding using method
> UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()). In
> gnome DE this call makes LAF==GTK. In other DE==Metal (LAF depends on
> openjdk, not distro).
> 2) Do not set any LAF in program, use System default settings (config
> file swing.properties). Due to some bugs, in Ubuntu default is Metal,
> previously was GTK.
>
> The request is to make hardcoded default LAF==GTK for all Linux
> distributions, or at least for KDE, Xfce, MATE and Cinnamon. There are a
> lot of Java apps (both closed-source and open-source) which hardcode
> system LAF. And they look ugly on linux, the workaround is to use
> _JAVA_OPTIONS=-Dswing..., but every time I run any java app I see
> annoying "Picked up _java_options ..."
>
> What I see now is: when I do not hardcode LAF in my java app it looks
> Metal on Windows and GTK on Linux. When I hardcode I see Native LAF on
> Windows and Metal on Linux ¯\_(ツ)_/¯
>
> Regards, Yan



More information about the swing-dev mailing list