This is my code. I need to know how to serach the area for certain text and then be able to replace it. I know I will have to use the replace () method somewhere in there to replace the text but not sure on how to search for it. ANy help youc ould provide woule be greatly appricated.
Basic: Use the String class which has indexOf() methods; you can repeatedly find a particular bit of text. it has replace() and replaceAll() method which creates a new String object. You doubtless already know you can't change a String.
Not quite so basic: Use the StringBuilder clasa (a more recent replacement for StringBuffer). It has methods for finding a particular index, and inserting or deleting text.
Maybe more advanced. Find the StrBuilder class in Jakarta Commons, which is similar to StringBuilder.
2. Consider what the earlier posts said to do with String data.
3. Put the modified String data back into the JTextArea.
Joined: Apr 19, 2007
so something like this,
Joined: Oct 13, 2005
No, 'fraid not.
Your JTextArea isn't a String. You need to get the text from it, which is in the form of a string, then you can use a replace method, or put it into a StringBuilder and use that to manipulate it. Then you can put the text back into the text area.