Hi Lillian, I notice that the painting performance of JTree breaks down when the tree has a certain size. The reason is that the JTree is painted as a whole, regardless of the current clip setting. This should really be improved because JTree is nearly not usable with bigger trees. This is especially important when used inside a JScrollPane, because when scrolling, usually only a thin line of some pixels must be repainted, the remainder is simply copied by the JViewport painting mechanism. However, I think in order to achieve this, you need to rework the JTree painting a little. At the moment the painting is performed recursivly, this seems wrong to me. This should really be implemented in a non-recursive way. Then we could do something like this: int startIndex = tree.getRowForLocation(clip.x, clip.y); int endIndex = tree.getRowForLocation(clip.x + clip.width, clip.y +clip.height); int current = startIndex; while (current <= endIndex) // Perform painting.... I think you are most familiar with this area, so I assign the bug to you.
Fixed. Reimplemented without using recursion.