Display Java’s Swing menus correctly in Linux Mint’s GTK LaF
Since GTK 3 has been introduced Java Swing applications have a bug in displaying their menus when using the GTK Look and Feel (LaF).
At Linux Mint Cinnamon:
- No border around dropdown and context menus
- Wrong font color of activated checkbox and radiobutton menu items (the font has the same color as the background and appears invisible)
- No menu separators
In the web there are some fixes and workarounds but just one solves the problem on Linux Mint 17 and later completely (see section “Interesting Links” below).
This How-To shows how to fix the problem and offers a bash script to get rid of this problem on Mint 17 and later automatically.
For Ubuntu find a small hint below.
The animated screenshot below shows the problem befor and after the fix.
The problem are entries in the “menus.rc” files of the Mint-themes at /usr/share/themes/
In Ubuntu the configuration is stored in different files (gtkrc), e.g.
/usr/share/themes/Adwaita/gtk-2.0/gtkrc. But the entries are pretty similar. Search for the section styles “menu” and look for the entries xthickness und ythickness. Set them to “1“. As an alternative install the Global Menu/HUD-Support for Java Swing Apps when you use the Unity desktop. See my posting Java’s Swing GTK LaF nice and pretty on Ubuntu for details.
Open the path /usr/share/themes/
[mint-theme]/gtk-2.0/style your used Mint-theme (e.g. “Mint-X”) as root und edit the file menus.rc.
In section style “menu” change:
xthickness = 0 ythickness = 0 text[ACTIVE] = @base_color
xthickness = 1 ythickness = 1 text[ACTIVE] = @fg_color
In section style “menu-item-separator” change the entry:
ythickness = 0
ythickness = 1
You are done for this theme.
To fix all Mint themes I recommend to use my bash script “swing-menu-corr.sh” below.
The changes have not effected general GTK applications at all!
Manually changing all menus.rc to fix the problem is time consuming. The bash script “swing-menu-corr.sh” does the changes in all files automatically.
The script changes only Mint Themes of Linux Mint 17.x! It works well with the Cinnamon and Xfce versions.
Update 2017-01-29: The script corrects Mint-X and Adwaita themes on Mint 17 or later only. Linux Mint 18’s Mint-Y themes are not supported (now). Refer workaround in my comment. This script works well with Mint’s Cinnamon and Xfce versions.
The script creates backup files of all changed files. You can undo the changes of “swing-menu-corr.sh” with the script “swing-menu-undo.sh” automatically.
Furthermore the script checks if it runs under Linux Mint 17.x. If not, it displays a warning. But do not worry. “Swing-menu-corr.sh” cannot damage your system seriously. The “undo” script can bring back the original files anyway.
|“swing-menu-corr.sh” at GitHub|
- K’s cluttered loft (Blog closed unfortunately) – Ubuntu-Fix
- Bug report @Java.com – Ubuntu
- GTKLookAndFeelFixer for Arduino
- bugs.launchpad.net/linuxmint – Comment of Peter Seng – fix for Mint