The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
February 2001

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Try this?

Posted by richard on February 23, 2001 at 5:06 AM

> I am new to java...& i have this project coming up..I'm been tring to do a search for a string feature in the project..The text i want to search is inputted through the JOptionPane & the area to be searched is JTextArea...After i find the string how can i get it selected in the JTextArea..
> Thanx in Advance..Pramod Chaly

I haven't bothered to look up the exact methods (but then neither have you!). Try something like this:

search for the substring using the indexOf method of the String Class - this returns the starting point of your target string. Then use the setSelectionStart and setSelectionEnd methods of the JTextArea.

hope this helps

richard




Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us