Lazy Tool Tips

At our group meeting today, we discussed the delays I had been seeing when Find All results were open and being updated, and I pasted text. A profiling session showed that a large percentage of the time was spent constructing the tool tips for the items in the RegionTreePanel. I don’t quite know why this was never an issue before, perhaps we simply didn’t update them.

The implementation was admittedly rather dumb, though, and created all tool tips at the time an item was inserted into the tree, even if the the tool tip was never displayed. I made the generation of the tool tips lazy by replacing the strings with thunks. Unfortunately, it’s impossible to subclass String in Java as it is final, but fortunately Swing was flexible enough to accept any object as property, as well as allowing me to override both setToolTipText() and getToolTipText().

I think this is actually a valuable addition that could be part of a future version of Swing, so I’d like to make the required changes easily available.

Share

About Mathias

Software development engineer. Principal developer of DrJava. Recent Ph.D. graduate from the Department of Computer Science at Rice University.
This entry was posted in DrJava. Bookmark the permalink.

Leave a Reply