Why doesn't Java GtkLookAndFeel Popups have a border?

I have a Java Swing application already written (so without switching user interface interfaces) that I would like to look at least worthy using GTKLookAndFeel. I've already taken into account things like font and component differences in LookAndFeels, but one thing I cannot understand is why there are no borders in my popup menu. It looks like they are using Synth borders that don't look GTK native. I would like to be able to support Metal, Windows and GTK, but these pop-ups look awful. This is mistake? What a good (non-hacky) way to fix this without affecting other LookAndFeels borders that look great?

+5
source share
4 answers

In my opinion, GTK LaF is disrupted by design. It does not comply with programmer user interface settings (background border color, etc.) for seemingly random JCOmponents. This is because it gets its settings from the .gtkrc file, and not for calls to setXXX (...). I would stick with Metal for Linux and "native" for Windows.

Answer:

The appearance of GTK + can be customized using resource files. Swing GTK + Appearance uses the following algorithm to search for resource files:

  • If the system property swing.gtkthemefile exists, analyze it and stop, for example: java -Dswing.gtkthemefile = / tmp / customTheme -jar SwingSet2.jar.
  • If user.home / .gtkrc-2.0 exists, analyze it and continue.
  • (THEMENAME) desktop gnome.net/ThemeName XSETTINGS. null, THEMENAME.      1. user.home/.themes/THEMENAME/gtk-2.0/gtkrc .      2. swing.gtkthemedir swing.gtkthemedir/THEMENAME/GTK-2.0/gtkrc , .      3. swing.gtkthemedir /usr/share/themes/THEMENAME/gtk -2.0/gtkrc , .      4. , swing.gtkthemedir swing.gtkthemedir/THEMENAME/GTK/gtkrc, /USR/ //THEMENAME/GTK/gtkrc.

GTK + . . 1.4.2, Default, pixmap bluecurve. API GTK. http://www.themes.org .
- http://java.sun.com/j2se/1.4.2/docs/guide/swing/1.4/Post1.4.html

, java rc .

+2

, , - google ( ), , , :

    if (UIManager.getLookAndFeel().getClass().getName().equals("com.sun.java.swing.plaf.gtk.GTKLookAndFeel"))
        aPopupMenu.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, Color.gray));

, , ( ), .

+2

rc .

, http://www.ailis.de/~k/ .

Ubuntu/Gnome Shell:, . /usr/share/themes/Adwaita/gtk-2.0/gtkrc

style "menu" { 
xthickness = 1 
ythickness = 1 ... 
} 
... style "separator_menu_item" { 
xthickness = 1 
ythickness = 1 
... }

11/30/2015: Ubuntu/Unity http://blog.hani-ibrahim.de/en/ubuntus-swing-gtk-laf.html = > , .

Linux Mint menus.rc Mint- /usr/share/themes/[mint-theme]/gtk-2.0/style

"" :

xthickness = 0
ythickness = 0
text[ACTIVE] = @base_color

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

"menu-item-separator" :

ythickness = 0

ythickness = 1

bash - script Mint, . 3 :

  • .
  • ( , , ).
  • .
+1

All Articles