aspose file tools
The moose likes Swing / AWT / SWT and the fly likes Search Function for a TextArea. Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "Search Function for a TextArea." Watch "Search Function for a TextArea." New topic
Author

Search Function for a TextArea.

john klucas
Greenhorn

Joined: Jul 31, 2001
Posts: 23
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!
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Search Function for a TextArea.
 
Similar Threads
Case Insensative search
June Newsletter Puzzle
some questions,please
Case Insensative search
How to update JList