aboutsummaryrefslogtreecommitdiff
path: root/libjava/classpath/javax/swing/tree/VariableHeightLayoutCache.java
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/classpath/javax/swing/tree/VariableHeightLayoutCache.java')
-rw-r--r--libjava/classpath/javax/swing/tree/VariableHeightLayoutCache.java22
1 files changed, 16 insertions, 6 deletions
diff --git a/libjava/classpath/javax/swing/tree/VariableHeightLayoutCache.java b/libjava/classpath/javax/swing/tree/VariableHeightLayoutCache.java
index a9ed552..0a787f7 100644
--- a/libjava/classpath/javax/swing/tree/VariableHeightLayoutCache.java
+++ b/libjava/classpath/javax/swing/tree/VariableHeightLayoutCache.java
@@ -162,7 +162,7 @@ public class VariableHeightLayoutCache
{
// This method may be called in the context when the tree rectangle is
// not known. To work around this, it is assumed near infinitely large.
- if (bounds==null)
+ if (bounds == null)
bounds = getNodeDimensions(node, row, depth, isExpanded,
new Rectangle());
return bounds;
@@ -232,6 +232,9 @@ public class VariableHeightLayoutCache
totalHeight = maximalWidth = 0;
+ if (treeModel == null)
+ return;
+
Object root = treeModel.getRoot();
if (rootVisible)
@@ -265,7 +268,7 @@ public class VariableHeightLayoutCache
if (expanded.contains(node))
{
int sc = treeModel.getChildCount(node);
- int deeper = depth+1;
+ int deeper = depth + 1;
for (int i = 0; i < sc; i++)
{
Object child = treeModel.getChild(node, i);
@@ -282,7 +285,7 @@ public class VariableHeightLayoutCache
public void invalidatePathBounds(TreePath path)
{
NodeRecord r = (NodeRecord) nodes.get(path.getLastPathComponent());
- if (r!=null)
+ if (r != null)
r.bounds = null;
}
@@ -555,9 +558,16 @@ public class VariableHeightLayoutCache
public void setModel(TreeModel newModel)
{
treeModel = newModel;
- // The root node is expanded by default.
- expanded.add(treeModel.getRoot());
- dirty = true;
+ // We need to clear the table and update the layout,
+ // so that we don't end up with wrong data in the tables.
+ expanded.clear();
+ update();
+ if (treeModel != null)
+ {
+ // The root node is expanded by default.
+ expanded.add(treeModel.getRoot());
+ dirty = true;
+ }
}
/**