JDK-6316684 : JButtons should draw their focus on Windows XP
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 6
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2005-08-26
  • Updated: 2010-04-02
  • Resolved: 2006-04-12
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 6
6 b80Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
I think that JButtons should draw their focus rectangle when running under Windows XP (with the XP theme). Currently they do not (except when inside of a toolbar) thanks to code in the paintFocus() method of the com.sun.java.swing.plaf.windows.WindowsButtonUI class. This code was put in there to supress the focus and I have seen cases where XP buttons in native apps *do* have focus rects. This needs to be investigated further to determine the correct behavior.

Comments
EVALUATION I have gone through the other bugs which involve the focus rect on Windows. All related bugs should be closed and added to this one with a see also. Some CRs mention that adding the focus rect is a regression vs Tiger. True, Tiger did not draw the focus rect on buttons (but did on toggle buttons) but this is incorrect behavior as detailed here. All buttons which are focusable should draw the focus.
10-03-2006

EVALUATION After more testing I have found the following components to use focus rects: button, combobox, checkbox, slider, radio button, links, and probably more. (more testing needed). It is true that toolbar buttons don't have focus rects, but they also don't get focus at all. Right now it is up to the developer of Swing application to make sure that their toolbar buttons don't receive the focus (perhaps we can add a global flag for this in the future). However, if the button receives the focus then it should draw definitely draw it's focus rect. Without that a user can tab off into oblivion.
10-03-2006

EVALUATION Looking at various Windows applications I have determined that most do draw focus rects, therefore we should too. Some applications don't draw the focus rect if you click on the button but only once you start tabbing. We cannot currently support this behavior, but we can at least draw the focus rect. Also, our focus rects on XP don't look quite like the native ones. They should be a bit closer to the button edges and they are slightly colored. The coloring varies between visual styles but I cannot find a property in the style which represents it. This may be a strange hardcoded effect. Some sort of composite drawing or XORing.
09-03-2006