Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Text-mouseover popups over a Swing JTextArea?

Tags:

Is there anything out there that allows you to show a small text popup window (like a tooltip) over individual words or letters in a Swing JTextArea? (Or a JTextArea alternative with similar functionality.)

What I need should behave like a tooltip, in other words only display the popup text after the mouse has hovered over the word for a second or two, and it would vanish automatically once the mouse moves away. Of course the tricky part here is that I want it at the character/word level within the text, not at the component level... any suggestions?

like image 281
Manius Avatar asked May 10 '11 22:05

Manius


1 Answers

You can override getToolTipText(Mouse Event event) as needed.

Addendum: JTextComponent, the parent of JTextArea provides location information via two methods: modelToView() and viewToModel(). The latter should let you translate the mouse location into a document offset.

like image 196
trashgod Avatar answered Nov 03 '22 00:11

trashgod