• Post Reply Bookmark Topic Watch Topic
  • New Topic

search abilities in JText?

 
Dean Watson
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm fairly new to Swing so sorry if this is too simple. I there build in ability to find text inside a JTEXT area? I know I can do a getText() and search for a string but this seem cludgy. can anyone share a better solution?
Thanks,
Dean
 
Robert , doodle
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
something like..
<pre>
int index=textArea.getText().indexOf(searchString);
textArea.setSelectionStart(index);
textArea.setSelectionEnd(searchString.length());
textArea.select(index,textArea.getSelectionEnd());
</pre>
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!