When using the default Adwaita theme in the Gtk+/gnome 3 environment, Java Swing programs that use local GTK + themes will appear with a borderless bug in the menu, which may also appear in other common GTK + topics. It is not too much to say that this is a bug in Java Swing or a bug in the Gtk+/gnome 3 theme (like Adwaita). Here is a simple solution, the idea is to modify the Gtk+/gnome 3 theme, here is the system default Adwaita topic for example:
The Adwaita theme file is located in the/usr/share/themes/adwaita directory, which contains gtk-2.0, gtk-3.0, QT and several subdirectories, we want to modify the gtk-2.0 subdirectory of the theme configuration file. Enter the/usr/share/themes/adwaita/gtk-2.0 directory, edit the main.rc file, find the "style" menu "{" line (probably the 1520th line), set xthickness and ythickness to:
11
Then add the following:
" Pixmap " { image { function = box file'assets/line.png " }}
After the above modifications, the Style "menu" section should look similar to the following:
Style"Menu"{xthickness=1ythickness=1Bg[normal]=@base_color Bg[insensitive]=@base_color Bg[prelight]=@base_color bg[selected]=@selected_bg_color engine"Pixmap"{image {function=BOXfile="Assets/line.png" } }}
Then find the "style" Separator_menu_item "{" line and modify it to the following:
style separator_menu_item " {xthickness = 1 ythickness = 1 engine " pixmap " function = box file = " assets/line.png
After modifying the Save main.rc, re-enabling the Adwaita theme to take effect, you will find that the Java Swing program uses the GTK + theme after the menu border finally appears normally. For other Gtk+/gnome 3 topics such as the Adwaita topic, this approach can be used to solve the problem.
Fix menu Borderless bug when Java Swing program uses local GTK + theme in Gtk+/gnome 3 environment