• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Move find and replace dialog to reveal matching word?

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?

Thanks.
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

To get better help sooner, post a SSCCE (Short, Self Contained, Compilable and Executable) example that demonstrates any remaining problem.
 
Minh Nam
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, look likes I have to do some mathematics myself.
 
You get good luck from rubbing the belly of a tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic