-
April 6th, 2012, 01:58 PM
#1
find string in Jtext area
i want to search a string in my JTextArea,but i m not able to find ne solution,what shud i write after dis code to search a string...pls help me solve dis out..
JTextArea logTextArea;
StringBuffer buffer=new StringBuffer(); /*it contains some random content appended in previous part of program... */
logTextArea.insert(buffer.toString(), logTextArea.getText().length());
-
April 6th, 2012, 02:40 PM
#2
Re: find string in Jtext area
I'm not sure exactly what you are asking. Could you please rephrase your question to make it clearer? What does 'search a string in my JTextArea' mean?
I would also advise using real English words, not text-speak. We are not all native English speakers. Bad spelling means you are putting unnecessary obstacles in the way of potential answerers, which in turn means a lot of people will just ignore your question.
-
April 6th, 2012, 05:05 PM
#3
Re: find string in Jtext area
Well, having known the string you're looking for it's pretty easy.
Textareatext=textarea.getText();
Int firstIndex = textareatext.indexOf(stringToLookFor,0);
Int lastIndex = firstIndex+stringToLookFor.length();
And now you pretty much have the starting and ending positions of your string... Is that what ur Asking?
-
April 6th, 2012, 08:26 PM
#4
Re: find string in Jtext area
Originally Posted by cens
Textareatext=textarea.getText();
Int firstIndex = textareatext.indexOf(stringToLookFor,0);
Int lastIndex = firstIndex+stringToLookFor.length();
What language is that?
Integers in Java are either int or Integer, not Int (Java is case sensitive). Also Textareatext != textareatext.
-
April 7th, 2012, 12:08 PM
#5
Re: find string in Jtext area
blame it on the auto-UpperCase my phone has
I know it's case sensitive, but by the way...was this what you were looking for, dilesh?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|