JDK-8023474 : First mousepress doesn't start editing in JTree
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 7,8
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2013-08-21
  • Updated: 2014-02-12
  • Resolved: 2013-08-26
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.
7u60Fixed 8 b110Fixed
Related Reports
Duplicate :  
Run the attached testcase with JDK 7 or JDK 8 and click on the check box on any tree node. The check box doesn't get selected or unselected. Now click again (second time) and you will see that check box editor is getting selected/unselected properly.
Verified by attached test CheckBoxTreeDemo java version "1.8.0-ea" Java(TM) SE Runtime Environment (build 1.8.0-ea-b112) Java HotSpot(TM) Client VM (build 25.0-b54, mixed mode) Linux virt 3.8.0-29-generic #42~precise1-Ubuntu SMP Wed Aug 14 15:31:16 UTC 2013 i686 i686 i386 GNU/Linux

Problem description: According to the current implementation of BasicTreeUI.startEdititng() we revalidate the editingComponent (so that it (along with its children) gets correct size and gets painted properly). And then we find the deepest component inside the editingComponent to dispatch the initial mouse event. But the issue here is since we call revalidate on editingComponent (if its a JComponent), the child components of editingComponent doest have proper bounds yet. The invocation of revalidate() will do it only asynchronously and the right sizes are not returned immediately. So SwingUtilities.getDeepestComponentAt() doesn't return the right child component within the editingComponent by this time. Suggested fix: We should find the first valid root for the editingComponent and call Container.validateUnconditionally() for it instead of revalidate() invocation.