JDK-6495117 : GTK L&F: non-default JButtons sized differently than native
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 6
  • Priority: P3
  • Status: Open
  • Resolution: Unresolved
  • OS: generic
  • CPU: generic
  • Submitted: 2006-11-17
  • Updated: 2011-04-28
Related Reports
Relates :  
Relates :  
Description
We're getting closer to ideal sizing of JButtons under GTK L&F
after the fixes for:
6489585: GTK L&F: buttons, checkboxes, and radiobuttons are sized incorrectly
6479305: GTK L&F: more toolbar issues

But while investigating 6479305, it was discovered that we are always leaving
enough space for the "default-border", even though most JButtons are not actually
the "default button" (i.e. isDefaultButton() returns false).  Ideally we would
only include room for the "default-border" if the button is in fact the default one.
Unfortunately, the ideal solution is complicated.  See comments section for an
email thread on the topic.

Comments
EVALUATION After more discussion, it seems that there's no compatible way to rely on isDefaultCapable() or isDefaultButton(). Since default buttons are less common than non-default ones, it probably makes sense to make non-default buttons match native exactly, and then apply some hack to default buttons. In my testing, I've found that most modern themes (Human, Clearlooks, Nimbus) have zero values for the "default-border" style property. The themes that do include a non-zero "default-border" (e.g. Simple, High Contrast) do so with small (one or two) pixel values. So one possible solution would be to not allocate extra space for "default-border" in getButtonInsets(), but do paint the "default-border" in paintButtonBackground(). This of course means that default buttons may not have the same size as native for the latter set of themes, and there's the possibility that the default border may not fit (since we haven't allocated extra space for it). But anyway, it's worth a shot, but will require testing on lots of themes to know for sure.
17-11-2006

EVALUATION See comments. The best fix hasn't yet been determined, but the general solution is outlined above.
17-11-2006