devxlogo

Finding Whole Words in a TextArea

Finding Whole Words in a TextArea

Question:
How do I find whole words in TextAreas? I have an application that is suppose to find particular words in a paragraph to see if you use certain words or phrases.

Answer:
The TextArea class is derived from TextComponent. The TextComponentclass contains a method called getText() which can be used to obtainthe entire text contained in a TextComponent. This method can becalled from TextArea as well. You can use getText() in conjunctionwith java.util.StringTokenizer or some other parsing class to searchthe contents of a TextArea.

devx-admin

Share the Post: