Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Search Function for a TextArea.  RSS feed

 
john klucas
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
i hope some one will help me out here.
i have a piece of code which basically searches whatever the user wants to search for. I have a TextArea which displays the o/p and a text field where users inputs whatever he wants to search for within that text area. But right now i am able to search only for one particular word. If user inputs a new word in place of the previous word it doesn't find that word or even if it finds it start searching from the index of the last word searched. i want the find, to start searching for a word again from the start index.
here is my code.
private void doFind()
{
String temp4 = "";
temp4 = ivjTextField1.getText();
String s3 = ivjTextArea1.getText();
int total = s3.length();

if(isfound ==false)
{
int ix = s3.indexOf(temp4);
if(ix >= 0)
{
lastindex = ix+temp4.length();
ivjTextArea1.select(ix, lastindex);
isfound = true;

}
}
else
{
int ix2 = s3.indexOf(temp4, lastindex+1);
if(ix2>=0)
{
lastindex = ix2+temp4.length();
ivjTextArea1.select(ix2, lastindex);
}

temp4 = null;

}
}
can any one help me out. Thanks in advance!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!