JDK-8065658 : Modernize the GTK3 Look and Feel implementation
  • Type: JEP
  • Component: client-libs
  • Sub-Component: javax.swing
  • Priority: P4
  • Status: Closed
  • Resolution: Withdrawn
  • Submitted: 2014-11-21
  • Updated: 2020-02-27
  • Resolved: 2020-02-27
Related Reports
Blocks :  
Relates :  
Description
**Summary**

Modernize the GTK3 Look and Feel implementation for OpenJDK.

**Motivation**

While OpenJDK ships with a set of Look and Feel (LAF) implementations for Swing, they are old and don't always follow modern design guidelines.

This problem is particularly acute in the case of Platform specific Look and Feel, where the various platforms supported have diverged significantly from what OpenJDK provides. On Linux, for example, almost every modern distribution uses GTK3 as its predefined GUI toolkit, while OpenJDK is still using GTK2. This is not only an issue because the UI may diverge considerably from native applications, but it is also a problem in some cases when using OpenJDK with applications that use native rendering directly, which may lead to crashes or other issues (see, for example, the following bug reports [here][1], [here][2] and [here][3]). There is a need to create new and improve existing implementations of Look and Feel in order to bring up the quality of GUI-based applications.

**Description**

This proposal focuses on adapting/rewriting the existing GTK2 LAF to use GTK3 instead. The resulting LAF will be usable independently of the existing implementations and not replace them, however it will not be possible to use both implementations at runtime, in other words the user will see this new implementation not as a new LookAndFeel but as a different version of the current GTKLookAndFeel. If this proposal is accepted, the current GTKLookAndFeel will be refactored in order to properly detect the version of gtk running on the host system and load the appropriate libraries; based on the detected version of the gtk native library, either the old Look And Feel or the new one will be used. It will be possible for users to force a specific implementation if both options are available, to ensure backward compatibility and help diagnosing bugs.

The new code should use only the public SynthLookAndFeel API and will not produce any public API. Any class or method introduced to support this new LAF will be internal, and should be appropriately restricted.

**Goals**

It is a goal of this JEP to implement a working Look and Feel based on GTK3.

**Non Goals**

While other look and feel in OpenJDK necessitate the same level of update, at this stage is not a goal of this JEP to provide other implementations.

**Success Metrics**

A valid implementation of a Look and Feel based on GTK3 that works well on most modern Linux Distribution with their default themes.

**Risks and Assumptions**

The only risk we foresee is the relationship of GTK2 and GTK3: those two API are not compatible and should not be mixed within one process. Since this proposal is about adding, not replacing, a GTK3 based implementation to the existing ones, the risk of breaking existing software is very minimal. Nevertheless, care must be taken to ensure that the new implementation will coexist correctly, for example ensuring that only one library between GTK2 and GTK3 can dlopened by OpenJDK.

**Dependences**

Other than the JDK itself, the new code will only be dependent on GTK3 and related dependencies.

**Testing**

The code will have appropriate test coverage. Also, while it is impossible to test every combination of GTK3 provided themes and applications, we will perform extensive testing on some well known Swing using programs, like NetBeans, JConsole, Thermostat, JVisualVM and the open source version of IDEA.


  [1]: http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=1736
  [2]: https://bugs.eclipse.org/bugs/show_bug.cgi?id=434560
  [3]: https://bugs.eclipse.org/bugs/show_bug.cgi?id=431330
Comments
I think we can withdraw it, most of the work that was necessary was done.
27-02-2020

The native part to use GTK3 + get the GTK3 themes from that is certainly done. Mario seemed to be also proposing updates in the Swing GTK LAF code to modernise that to GTK3 standards/styles, but I don't know how much effort was intended to go in that direction, but it seems to be the main part that has not been investigated.
26-03-2018

Is there any reason any more, then, for this JEP? [~neugens] If not, could you please withdraw it? Thanks.
26-03-2018

JDK 10 is literally done. The GAC build already exists (even if if has not been published). However this is a good time to consider it for JDK 11. I submitted https://bugs.openjdk.java.net/browse/JDK-8198649
23-02-2018

Great to hear! Thanks for the update, Phil. I see a vast performance uplift in the swing benchmark i use to measure swing theme performance with xrender - thanks to the ability of GTK3 to render to in-memory surfaces: 850ms vs 2400ms on MigLayout Benchmark - hopefully it will be the default for JDK10.
23-02-2018

It was in some part replaced by http://openjdk.java.net/jeps/283 which was implemented for the AWT/Swing stack as well as FX. So Swing's GTK L&F should pick up a GTK theme when you enable GTK3 by -Djdk.gtk.version=3 https://docs.oracle.com/javase/9/whatsnew/toc.htm#JSNEW-GUID-983469B6-9BB5-48CA-B71D-8D7012B2F3CA Perhaps for a future release we can make it the default but you have to opt in for now.
23-02-2018

What happend with this enhancement?
23-02-2018

Amend specification to note that we aim for one LookAndFeel, with different implementations.
25-11-2014