JDK-6365773 : GTK L&F: menu separators do not match native ones
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 5.0
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: solaris_10
  • CPU: generic
  • Submitted: 2005-12-21
  • Updated: 2011-03-09
  • Resolved: 2011-03-08
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7 b03Fixed
Related Reports
Relates :  
Description
See attached screenshots (terminal-submenu-native.png shows native GTK menu,
terminal-submenu-java.png shows Swing GTK L&F from Mustang b63 on Solaris Nevada b27a).
Note the differences with the Blueprint theme (similar issues with other themes):
  - native separator images is 3 pixels tall, Swing's is only 2 pixels tall
  - native separator has some padding on top and bottom, Swing's does not
  - native separator has padding on left and right (about 5 pixels on each side),
    Swing's extends all the way to the edges

Comments
EVALUATION This will be fixed at the same time as 6452493, since the fixes are related.
29-09-2006

EVALUATION There are a few issues that contribute to this bug: 1. SynthSeparatorUI.getPreferredSize() uses JComponent.getInsets(), but GTKLookAndFeel defines a Separator.insets value (2), so perhaps getPreferredSize() should check Separator.insets instead? (This won't really affect this bug, but is something we should maybe consider fixing for synth.) 2. GTKPainter.getInsets() only checks for Region.SEPARATOR, but we also need to check for Region.POPUP_MENU_SEPARATOR (they should be treated the same, as they are elsewhere in GTK L&F code), like this: else if (id == Region.SEPARATOR || id == Region.POPUP_MENU_SEPARATOR) { return getSeparatorInsets(state, insets); 3. GTKPainter.getSeparatorInsets() currently returns zero insets. We need to take x/y thickness values into account, as well as the "horizontal-padding" state that is defined for GTK separators, like this: private Insets getSeparatorInsets(SynthContext context, Insets insets) { + GTKStyle style = (GTKStyle)context.getStyle(); + int horizPadding = + style.getClassSpecificIntValue(context, "horizontal-padding", 0); + insets.right = insets.left = style.getXThickness() + horizPadding; + insets.top = insets.bottom = style.getYThickness(); return insets; } Note that with these changes in place, Swing's GTK L&F will now render separators properly so that they match the native behavior. For example, in Blueprint the horizontal-padding value is 3, and the x/y thickness is 2, so we will end up with left/right insets of 5 and top/bottom insets of 2, which exactly matches what you will see in a native GTK menu. This formula seems to work well for other themes such as Clearlooks. X. Not really related, but why does SynthStyle.getInsets() zero out the passed insets parameter? Seems like strange behavior...
21-12-2005