• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

search abilities in JText?

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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>
 
reply
    Bookmark Topic Watch Topic
  • New Topic