Fix menu Borderless bug when Java Swing program uses local GTK + theme in Gtk+/gnome 3 environment

Source: Internet
Author: User
Tags gtk

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.