JDK-8203627 : Swing applications with JRadioButton and JCheckbox fail to render correctly when using GTK3 and the GTK L&F
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 9,10,11,12
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: linux_ubuntu
  • CPU: x86_64
  • Submitted: 2018-05-18
  • Updated: 2019-09-26
  • Resolved: 2019-02-15
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 11 JDK 12 JDK 13 JDK 8 Other
11.0.4-oracleFixed 12.0.2Fixed 13 b09Fixed 8u221Fixed openjdk8u222Fixed
Related Reports
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Description
ADDITIONAL SYSTEM INFORMATION :
AMD64, Ubuntu 18.04 Bionic, OpenJDK 10.0.1.

Please note that while Debian name their OpenJDK 10 packages as openjdk-10 in Ubuntu Bionic they are named openjdk-11 in order to provide an easier upgrade path to user then OpenJDK 11 is released.

A DESCRIPTION OF THE PROBLEM :
Swing/AWT applications using the GTK L&K render incorrectly under GTK3. If GTK2 is used then they render as expected.

This has been reported in Ubuntu [1] and Debian [2], but as reported in [1] the Oracle JDK 10 is also affected.

Debian and Ubuntu both package OpenJDK 10.0.1, additionally we also apply the patch for JDK-8198649 thus making GTK3 the default.

Ubuntu and Debian render correctly when forcing GTK2 by setting -Djdk.gtk.version=2.

Oracle's JDK 10 also show the same problems when forcing GTK3 usage by setting -Djdk.gtk.version=3.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Install the JRE and Demo packages and run the FileChooserDemo under GTK3 and GTK2.

Under Debian:
$ sudo apt-get install default-jre openjdk-10-demo
$ java -jar /usr/share/doc/openjdk-10-jre-headless/demo/jfc/FileChooserDemo/FileChooserDemo.jar

Now run it using GTK2 for the correct rendering:
$ java -Djdk.gtk.version=2 -jar /usr/share/doc/openjdk-10-jre-headless/demo/jfc/FileChooserDemo/FileChooserDemo.jar

On Ubuntu packages OpenJDK 10.0.1 under binary packages named as openjdk-11:
$ sudo apt-get install default-jre openjdk-11-demo
$ java -jar /usr/share/doc/openjdk-11-jre-headless/demo/jfc/FileChooserDemo/FileChooserDemo.jar

Now run it using GTK2 for the correct rendering:
$ java -Djdk.gtk.version=2 -jar /usr/share/doc/openjdk-11-jre-headless/demo/jfc/FileChooserDemo/FileChooserDemo.jar

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Checkbox and the selection box element should be rendered correctly.
ACTUAL -
The GTK3 based rendering is failing to draw the checkbox and the selection box element correctly.

---------- BEGIN SOURCE ----------
The FileChooserDemo from OpenJDK.
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Setting -Djdk.gtk.version=2 forces the system to use GTK2 libraries which render correctly, but the user might not have those installed as Debian and Ubuntu are removing all dependencies on GTK2 in order to complete the move to GTK3.

FREQUENCY : always



Comments
Fix Request (11u, 8u) This issue solves GTK 3+ compatibility problems. Upstream patch contains fixes for 4 issues (JDK-8218469, JDK-8218470, JDK-8218472, JDK-8203627). It applies cleanly to 11u (and I see 11.0.4-oracle), and to 8u with reshuffling (and I see 8u221/222). Original tests (JSlider, JProgressBar, JScrollBar, FileChooserDemo) work fine after the patch, and looks wrong before the patch. 8u requires -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel -Djdk.gtk.version=3 to reproduce. The risk is low.
18-03-2019

This is an issue with gtk version 3.20 and later. gtk has made some major changes in their theme handling in gtk 3.20 and applications need to change to adapt to those changes. This issue is reproducible in Ubuntu 18.04 and OEL 7.5 as the gtk version is >3.20 in both whereas in Ubuntu 16.04, the default version is 3.18 and works fine. Further investigation needs to be done on exactly what changes are required to make this work with gtk version >=3.20 I have verified this by installing gtk 3.20 on Ubuntu 16.04 and this issue is observed there. I also wrote a small native gtk3 demo and similar behavior is observed.
04-01-2019

I have done some analysis on this and all looks correct from gtk3 side. I will have to see why there is difference between behaviour in Ubuntu 18.04 and Ubuntu 16.04 as this is working fine on Ubuntu 16.04 LTS
02-01-2019

Re targeting it to 12, please continue working and if it is ready before June 26, please bring it back to 11
21-06-2018

Without any option in commandline, the test passes for me. But with explicit setting of -Djdk.gtk.version=3 -Djdk.gtk.verbose=true, it fails. But, it seems same jdk11 workspace (or jdk11 b16) passes on ubuntu16.04 with same commandline (which shows GTK3 is loaded) but fails on 17.10 and 18.04. ubuntu16.04 uses gtk3.18.9, ubuntu 17.10 uses gtk3.22.25, ubuntu18.04 uses gtk3.22.30.
17-06-2018

Followed same steps as provided by Submitter: $ sudo apt-get install default-jre openjdk-11-demo $ java -jar /usr/share/doc/openjdk-11-jre-headless/demo/jfc/FileChooserDemo/FileChooserDemo.jar PFA screenshots of ran demo test case with OpenJDK 10.0.1 with 1. default GTK3 (Ubuntu_18.04_GTK3.png) : When changed Laf to GTK+, checkbox and the selection box are not rendered correctly 2. With ' -Djdk.gtk.version=2' (Ubuntu_18.04_GTK2.png) : changed Laf to GTK+, checkbox and the selection box are rendered correctly
15-06-2018

Upgrade 17.10 to 18.04 as I do not have space to install new one from scratch. Also, I tried default setting before login which gave 3 options "Ubuntu", "Ubuntu with wayland" and "Unity" and for me all 3 works.
11-06-2018

As far as I know the latest Ubuntu 18.04 uses gnome3 by default. Did you install ubuntu from scratch or update the existed?
11-06-2018

I used Unity UI for ubuntu 18.04 echo $XDG_CURRENT_DESKTOP Unity:Unity7:ubuntu
11-06-2018

I run the FileChooserDemo in ubuntu18.04 (attached screenshot) with jdk11-b16 but I could not see the issue, the checkboxes are shown correctly.
01-06-2018

Response from Submitter: ----------------------------- 1) The FileChooserDemo allows one to select a Look and Feel, in order to reproduce the issue the LaF must be set to GTK after it opens, otherwise it starts on Nimbus (which just works). 2) I missed to link the bugs referenced by [1] and [2], which are [1] https://launchpad.net/bugs/1770278 and [2] https://bugs.debian.org/897629 (the first one has some screenshots from Netbeans). 3) The Tree component is also affected as it can be seen in the screenshots from Netbeans from the launchpad bug. Please note that using -Dswing.defautlaf does not work with the FileChooserDemo, it ignores that setting and starts on Nimbus LaF. I'm providing one screenshot now. The top half is the FileChooserDemo in the default LaF (Nimbus,unaffected by jdk.gtk.version as expected), the left bottom half is the GTK LaF with -Djdk.gtk.version=3, while the right bottom half is with the GTK LaF and -Djdk.gtk.version=2. Installed GTK on my system seems to match yours: libgtk-3-0:amd64 3.22.30-1ubuntu1 amd64 GTK+ graphical user interface library libgtk2.0-0:amd64 2.24.32-1ubuntu1 amd64 GTK+ graphical user interface library ------------------------------------- Issue is now reproducible as mentioned in bug description. 1. Ran demo test case with OpenJDK 10.0.1 and changed Laf to GTK+, checkbox and the selection box are not rendered correctly. When ran with ' -Djdk.gtk.version=2', checkbox and the selection box are rendered correctly. 2. When ran the test case using Oracle JDK 10.0.1+10 without any gtk setting, there is no issue after changing laf to GTK+. But when ran with setting -Djdk.gtk.version=3, checkbox and the selection box are not rendered correctly. 3. When ran the test case using Oracle JDK 11-ea+13 without any gtk setting, checkbox and the selection box are not rendered correctly afer changing Laf to GTK+. When ran with setting -Djdk.gtk.version=2, it renders correctly.
23-05-2018

Installed Ubuntu Bionic 18.04 and OpenJDK 10.0.1 using same commands as mentioned in bug description but could not reproduce the issue: $ sudo apt-get install default-jre openjdk-11-demo $ java -jar /usr/share/doc/openjdk-11-jre-headless/demo/jfc/FileChooserDemo/FileChooserDemo.jar All checkboxes and the selection boxes are rendered correctly. Also ran same demo test case using Oracle JDK 10.0.1+10 with GTK3 usage by setting -Djdk.gtk.version=3, but again issue is not reproducible. Requested Submitter for additional information (screenshot and exact steps to reproduce issue) Installed GTK version : ||/ Name Version Architecture Description ==============-============-============ ii libgtk-3-0:amd 3.22.30-1ubu amd64 GTK+ graphical user interface lib ii libgtk2.0-0:am 2.24.32-1ubu amd64 GTK+ graphical user interface lib
22-05-2018