JDK-6323239 : Problems with BoxLayout and JToolBar.DefaultToolBarLayout
  • 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-09-13
  • Updated: 2010-09-30
  • Resolved: 2005-09-20
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 b53Fixed
Related Reports
Relates :  
Description
Ran the attached test case, clicking the 'Press Me' button.  You get the following exception:

Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 1
	at javax.swing.SizeRequirements.expandedTile(SizeRequirements.java:355)
	at javax.swing.SizeRequirements.calculateTiledPositions(SizeRequirements.java:299)
	at javax.swing.BoxLayout.layoutContainer(BoxLayout.java:378)
	at javax.swing.JToolBar$DefaultToolBarLayout.layoutContainer(JToolBar.java:762)
	at java.awt.Container.layout(Container.java:1395)
	at java.awt.Container.doLayout(Container.java:1384)
	at java.awt.Container.validateTree(Container.java:1467)
	at java.awt.Container.validateTree(Container.java:1474)
	at java.awt.Container.validateTree(Container.java:1474)
	at java.awt.Container.validateTree(Container.java:1474)
	at java.awt.Container.validate(Container.java:1442)
	at javax.swing.RepaintManager.validateInvalidComponents(RepaintManager.java:602)
	at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:127)
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)

Also take a look at recent (01-Mar-2005) JDC comments to 4294758.  I suspect those people are running into this bug.

Comments
EVALUATION This is happening because BoxLayout assumes invalidateLayout will be called after every remove/add, which isn't necessarily the case. The fix is to have add/remove clear the caches just as invalidateLayout does.
13-09-2005