Here you can find the source of redrawAllTreeCells(DefaultTreeModel treeModel)
Parameter | Description |
---|---|
treeModel | a parameter |
public static void redrawAllTreeCells(DefaultTreeModel treeModel)
//package com.java2s; //License from project: BSD License import javax.swing.tree.DefaultTreeModel; import javax.swing.tree.TreeNode; public class Main { /**// w w w. jav a2s . co m * Repaints the cells for all the tree nodes in the tree represented by the given tree model. This * is particularly useful when the renderer for a tree has changed leaving us open to the * possibility that the new renderer will leave the nodes' text cut off and an ellipsis at the * end. Note: The root node must be a TreeNode. * * @param treeModel */ public static void redrawAllTreeCells(DefaultTreeModel treeModel) { Object root = treeModel.getRoot(); if (root instanceof TreeNode) { redrawAllTreeCellsRec(treeModel, (TreeNode) root); } else { System.err.println("Error: Tree root is not a TreeNode"); } } private static void redrawAllTreeCellsRec(DefaultTreeModel treeModel, TreeNode parent) { treeModel.nodeChanged(parent); for (int i = 0; i < parent.getChildCount(); i++) { redrawAllTreeCellsRec(treeModel, parent.getChildAt(i)); } } }