Move find and replace dialog to reveal matching word?
Joined: Sep 10, 2011
Hi my friends,
I am writing a text editor which has a find and replace feature.
I am facing a problem, that is, sometimes the find and replace dialog hides the matching word. I would like to hear your suggestion about:
- how to determine if the dialog is hiding the matching word?
- how to determine a new location for dialog to let the user can see the matching word?
JTextComponent#modelToView(int pos) in conjunction with other methods that you are probably already using can get you the Rectangle for the start and end of the word. The rest should be straightforward mathematics.