swing-menus_featured

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 unvisible)
  • No menu separators

In the web there are some fixes and workarounds but just one solves the problem on Linux Mint 17 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.x automatically.

For Ubuntu find a small hint below.

The animated screenshot below shows the problem befor and after the fix.

Menübug in Swings GTK LaF vor und nach der Fehlerbeseitigung
Menu bug in Swing’s GTK LaF befor and after the fix

The problem are entries in the “menus.rc” files of the Mint-themes at /usr/share/themes/[mint-theme]/gtk-2.0/style.

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.

Manuel Fix

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

to:

xthickness = 1
ythickness = 1
text[ACTIVE] = @fg_color

In section style “menu-item-separator” change the entry:

ythickness = 0

to:

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!

Automatic Fix

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.

Swing-menu-corr.sh-Skript
Swing-menu-corr.sh-script

The script changes only Mint Themes of Linux Mint 17.x! It works well with the 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.

Download

logo_mint “swing-menu-corr.sh” at GitHub
Logo Java Java-Testprogram “Menutest.tar.gz

One thought on “Display Java’s Swing menus correctly in Linux Mint’s GTK LaF”

Leave a Reply

Your email address will not be published. Required fields are marked *