JDK-6293377 : Win L&F: REGRESSION: JButtons inside a JToolBar should not be focusable in Windows PLAF
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.4.2
  • Priority: P2
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2005-07-01
  • Updated: 2010-05-10
  • Resolved: 2005-09-07
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
6Resolved
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.4.2_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2
Java HotSpot(TM) Client VM (build 1.4.2_06-b03, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows 2000 [Version 5.00.2195]
Service Pack 4

A DESCRIPTION OF THE PROBLEM :
This report was a result of investigation into Bug 4758890.

Windows applications do not allow buttons to be focusable when they are part of a toolbar. You cannot traverse focus via the tab key or invoke a button click with the spacebar.  This is not the case in Java using Windows PLAF.  The fact that Java allows this is opening the door to reporting of other bugs eg 4758890 as a result.

If Java provides a Windows Look and Feel, it should properly support it.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Run WindowsUIToolBarTest class.
2. Click on one of the toolbar buttons.
3. press the spacebar and notice the button depress.
4. press the tab button once then press the spacebar.

Result is focus has changed to the other button and spacebar invokes click.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The toolbar buttons should not be focusable so spacebar shouldn't activate a click and tab should not transfer focus.
ACTUAL -
Buttons can actually have focus though the focus is not painted.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import javax.swing.*;


public class WindowsUIToolBarTest{


	public static void main(String args[]) throws Exception {
		UIManager.setLookAndFeel(new com.sun.java.swing.plaf.windows.WindowsLookAndFeel());

		JFrame frame = new JFrame();
		JPanel panel = new JPanel();
		JButton button = new JButton("Press Me");
		JButton button2 = new JButton("Press Me2");

		//button.setFocusable(false);  <- workaround
		//button2.setFocusable(false); <- workaround

		JToolBar toolbar = new JToolBar();
		toolbar.add(button);
		toolbar.add(button2);

		panel.add(toolbar);

		frame.setContentPane(panel);
		frame.setSize(200, 300);
		frame.setVisible(true);
	}
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Set button's focusable property to false when using Windows PLAF.

Release Regression From : 1.4.2
The above release value was the last known release where this 
bug was known to work. Since then there has been a regression.
###@###.### 2005-07-01 10:11:53 GMT

Comments
EVALUATION We have a fix in progress. There will be a client property the application developer can set to force the buttons inside of a jtoolbar to not be focusable.
10-08-2005