src/share/classes/javax/swing/plaf/basic/BasicTreeUI.java
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
@@ -25,10 +25,11 @@
package javax.swing.plaf.basic;
import javax.swing.*;
import javax.swing.event.*;
+import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import java.awt.datatransfer.*;
import java.beans.*;
import java.util.Enumeration;
@@ -40,10 +41,11 @@
import javax.swing.plaf.UIResource;
import javax.swing.plaf.TreeUI;
import javax.swing.tree.*;
import javax.swing.text.Position;
import javax.swing.plaf.basic.DragRecognitionSupport.BeforeDrag;
+import sun.awt.AWTAccessor;
import sun.swing.SwingUtilities2;
import sun.swing.DefaultLookup;
import sun.swing.UIAction;
@@ -2163,12 +2165,18 @@
tree.add(editingComponent);
editingComponent.setBounds(nodeBounds.x, nodeBounds.y,
nodeBounds.width,
nodeBounds.height);
editingPath = path;
+
+ Container validateRoot = null;
if (editingComponent instanceof JComponent) {
- ((JComponent)editingComponent).revalidate();
+ validateRoot = getValidateRoot((Container)editingComponent, true);
+ }
+
+ if (validateRoot != null) {
+ AWTAccessor.getContainerAccessor().validateUnconditionally(validateRoot);
} else {
editingComponent.validate();
}
editingComponent.repaint();
if(cellEditor.shouldSelectCell(event)) {
@@ -2217,10 +2225,41 @@
editingComponent = null;
}
return false;
}
+ // The implementation of the method is copied from SwingUtilities
+ private Container getValidateRoot(Container c, boolean visibleOnly) {
+ Container root = null;
+
+ for (; c != null; c = c.getParent())
+ {
+ if (!c.isDisplayable() || c instanceof CellRendererPane) {
+ return null;
+ }
+ if (c.isValidateRoot()) {
+ root = c;
+ break;
+ }
+ }
+
+ if (root == null) {
+ return null;
+ }
+
+ for (; c != null; c = c.getParent()) {
+ if (!c.isDisplayable() || (visibleOnly && !c.isVisible())) {
+ return null;
+ }
+ if (c instanceof Window || c instanceof Applet) {
+ return root;
+ }
+ }
+
+ return null;
+ }
+
//
// Following are primarily for handling mouse events.
//
/**