I’m trying to set tooltips on a JEditorPane. The method which I use to determine what tooltip text to show is fairly CPU intensive – and so I would like to only show it after the mouse has stopped for a short amount of time – say 1 second.
I know I can use ToolTipManager.sharedInstance().setInitialDelay(), however this will set the delay time for tooltips on all swing components at once and I don’t want this.
Well, I would recommend doing the CPU intensive task on another thread so it doesn’t interrupt normal GUI tasks.
That would be a better solution. (instead of trying to circumvent the problem)
*Edit* You could possibly calculate the tootips for every word in the
JEditorPaneand store them in aMap. Then all you would have to do is access the tootip out of theMapif it changes.Ideally people won’t be moving the mouse and typing at the same time. So, you can calculate the tootlips when the text changes, and just pull them from the
MaponmouseMoved().