This fixes the JTree bug with OpenJump. We simply shouldn't call
updateUI() from within setModel(). This causes a big re-setup of the
JTree, including some messing around with the model, which ends up
installing the wrong nodes, thus leading to the CCE reported in
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27651
This liberates OpenJump to a certain degree:
http://kennke.org/~roman/openjump.png
2006-06-06 Roman Kennke <[EMAIL PROTECTED]>
PR 27651
* javax/swing/JTree.java
(JTree(TreeModel)): Call updateUI() before setModel().
(setModel): Don't call updateUI here.
/Roman
Index: javax/swing/JTree.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/JTree.java,v
retrieving revision 1.67
diff -u -1 -0 -r1.67 JTree.java
--- javax/swing/JTree.java 1 Jun 2006 04:38:49 -0000 1.67
+++ javax/swing/JTree.java 6 Jun 2006 15:28:01 -0000
@@ -1502,27 +1502,27 @@
}
/**
* Creates a new <code>JTree</code> object.
*
* @param model the model to use
*/
public JTree(TreeModel model)
{
setRootVisible(true);
- // The setModel also calls the updateUI
- setModel(model);
setSelectionModel(new EmptySelectionModel());
selectionModel.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
// The root node appears expanded by default.
nodeStates.put(new TreePath(model.getRoot()), EXPANDED);
+ updateUI();
+ setModel(model);
}
/**
* Creates a new <code>JTree</code> object.
*
* @param root the root node
*/
public JTree(TreeNode root)
{
this(root, false);
@@ -1900,21 +1900,20 @@
// add treeModelListener to the new model
if (treeModelListener == null)
treeModelListener = createTreeModelListener();
if (model != null) // as setModel(null) is allowed
model.addTreeModelListener(treeModelListener);
TreeModel oldValue = treeModel;
treeModel = model;
firePropertyChange(TREE_MODEL_PROPERTY, oldValue, model);
- updateUI();
}
/**
* Checks if this <code>JTree</code> object is editable.
*
* @return <code>true</code> if this tree object is editable,
* <code>false</code> otherwise
*/
public boolean isEditable()
{