Swing applications look strange with OpenJDK-11

Bug #1770278 reported by Martin Weißhaupt on 2018-05-09
16
This bug affects 2 people
Affects Status Importance Assigned to Milestone
openjdk-10 (Debian)
Fix Released
Unknown
openjdk-lts (Ubuntu)
Undecided
Unassigned

Bug Description

I have noticed that NetBeans looks strange with OpenJDK 11. It seems to use GTK3 widgets are used which have a different padding than GTK2 widgets.

The screenshots show NetBeans 8.2 running on JDK9 and NetBeans 9-Dev running on OpenJDK 11 but it doesn't matter which application or version is used.

Switching to JDK8 or JDK9 or using the Metal look and feel or Nimbus look and feel also fixes the issue.
Also starting NetBeans with Oracle JDK 11 does not have any drawing issue.

ProblemType: Bug
DistroRelease: Ubuntu 18.04
Package: openjdk-11-jdk 10.0.1+10-3ubuntu1
ProcVersionSignature: Ubuntu 4.15.0-20.21-generic 4.15.17
Uname: Linux 4.15.0-20-generic x86_64
ApportVersion: 2.20.9-0ubuntu7
Architecture: amd64
CurrentDesktop: GNOME
Date: Thu May 10 00:09:07 2018
InstallationDate: Installed on 2016-10-25 (561 days ago)
InstallationMedia: Ubuntu 16.10 "Yakkety Yak" - Release amd64 (20161012.2)
ProcEnviron:
 TERM=xterm-256color
 PATH=(custom, no user)
 XDG_RUNTIME_DIR=<set>
 LANG=de_DE.UTF-8
 SHELL=/bin/bash
SourcePackage: openjdk-lts
UpgradeStatus: Upgraded to bionic on 2018-04-24 (15 days ago)

Martin Weißhaupt (mweisshaupt) wrote :
Tiago Stürmer Daitx (tdaitx) wrote :

Thank you for taking the time to report this bug and helping to make Ubuntu better.

Could you please try adding -Djdk.gtk.version=3 to the java command line to check if it solves the problems and then reporting back?

If it does help then the issue might be solved by backporting https://bugs.openjdk.java.net/browse/JDK-8198649.

Tiago Stürmer Daitx (tdaitx) wrote :

> Also starting NetBeans with Oracle JDK 11 does not have any drawing issue.
What about Oracle's JDK 10, is it fixed there? It would be a better comparison than JDK 11.

Reasoning: although our package is named openjdk-11 it is actually running openjdk-10 (thus the 10.0.1+10-3ubuntu1 version). It might seem misleading, but that is in place so we can make the upgrade path to our users easier when OpenJDK 11 gets released in September this year.

Changed in openjdk-lts (Ubuntu):
status: New → Incomplete
Changed in openjdk-10 (Debian):
status: Unknown → New
Martin Weißhaupt (mweisshaupt) wrote :

Sorry I got confused about version 11 and 10. I meant Oracle JDK 10. This release does not have the issue unless I add -Djdk.gtk.version=3 on command line.

I also noticed that the issue goes away if I start NetBeans and other applications on OpenJDK-11 (which is actually version 10 on Ubuntu) with this flag: -Djdk.gtk.version=2

It seems that this issue occurs because of the padding used in GTK3 widgets. A quick fix would be to set GTK2 as default for now but what happens when GTK2 will be phased out?

Tiago Stürmer Daitx (tdaitx) wrote :

Thanks for the feedback. Indeed, Ubuntu's (and Debian's) OpenJDK actually applies the patch from JDK-8198649 in order to enable GTK3 by default in OpenJDK 10, while upstream that has only applied that to OpenJDK 11 which has not yet been released.

That's why Oracle's JDK 10 works fine unless you set the -Djdk.gtk.version=3: they still default to gtk2 when both are installed.

I'll be looking into this later in the day and will report it upstream if needed - OpenJDK 11 is in Early Release, so there aren't a lot of users trying it yet.

Tiago Stürmer Daitx (tdaitx) wrote :

I have reported it under https://bugreport.java.com and got the bug number 9053855 - it is now under review by Oracle, I will update it here when they make the report public.

Tiago Stürmer Daitx (tdaitx) wrote :

The bug was opened at the main bugs.java.com bug tracking.

https://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8203627

Please note that only OpenJDK Authors (and above) and sign in and update the bug.

Changed in openjdk-10 (Debian):
status: New → Fix Released
Tiago Stürmer Daitx (tdaitx) wrote :

There has been some recent updates in the upstream bug [1,2] - too bad that Launchpad cannot track it.

From January 3rd:
"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".

From last week:
"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."

The fix [3] was added to 11.0.4 (not yet release) so I will backport and test it for Bionic's and Cosmic's OpenJDK 11.

References:
[1] https://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8203627
[2] https://bugs.openjdk.java.net/browse/JDK-8203627
[3] http://hg.openjdk.java.net/jdk-updates/jdk11u-dev/rev/fa3eed43d5fa

Tiago Stürmer Daitx (tdaitx) wrote :

I applied the fix, build a new openjdk for the test and saw a bit of an improvement, but some widgets are still looking weird. JComboBox from JFileChooser still looks wrong.

The jabref app has some weird spacing in various widgets, including its toolbar. Meanwhile it also has the broken JComboBox and the JTable. I might have missed some.

Tiago Stürmer Daitx (tdaitx) wrote :

A comparison between GTK3 (with and without the fix) and GTK 2.
Top: GTK3 running under OpenJDK 11 with the fix applied (see how JComboBox is still broken)
Center: GTK3 without the fix (as originally reported)
Bottom: GTK2, looking ok

Changed in openjdk-lts (Ubuntu):
status: Incomplete → Triaged
Tiago Stürmer Daitx (tdaitx) wrote :

Comparison of jabref from bionic-proposed running under openjdk-11 with the upstream fix under GTK3 (top) and GTK2 (bottom).

$ apt policy jabref
jabref:
  Installed: 3.8.2+ds-12~18.04
  Candidate: 3.8.2+ds-12~18.04
  Version table:
 *** 3.8.2+ds-12~18.04 500
        500 http://archive.ubuntu.com/ubuntu bionic-proposed/universe
amd64 Packages
        500 http://archive.ubuntu.com/ubuntu bionic-proposed/universe
i386 Packages
        100 /var/lib/dpkg/status
     3.8.2+ds-3 500
        500 http://archive.ubuntu.com/ubuntu bionic/universe amd64 Packages
        500 http://archive.ubuntu.com/ubuntu bionic/universe i386 Packages

Tiago Stürmer Daitx (tdaitx) wrote :

jabref general preferences window running under openjdk-11 with the upstream fix applied:
top: gtk2
bottom: gtk3

Tiago Stürmer Daitx (tdaitx) wrote :

jabref entrytable preferences window running under openjdk-11 with the upstream fix applied, JTable is still badly draw (no left border, as if cropped) and the select box has no borders.

top: gtk2
bottom: gtk3

Launchpad Janitor (janitor) wrote :

This bug was fixed in the package openjdk-lts - 11.0.3+5-1ubuntu2

---------------
openjdk-lts (11.0.3+5-1ubuntu2) disco; urgency=medium

  * Fix configuring with the vendor flags.

 -- Matthias Klose <email address hidden> Tue, 02 Apr 2019 16:42:19 +0200

Changed in openjdk-lts (Ubuntu):
status: Triaged → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.