File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Which Listener to use for JTextArea Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Which Listener to use for JTextArea" Watch "Which Listener to use for JTextArea" New topic
Author

Which Listener to use for JTextArea

Parth Bhatt
Ranch Hand

Joined: Oct 19, 2005
Posts: 58
Hello !!

I am stuck with a problem where i need to observe a JTextArea and restrict the maximum number of characters that can be input to 200. I need to know which Listener can i use for this pourpose....

Specifically, i need to know the Listener that i can add to my JTextArea object so that a perticular method is called as soon as a character is entered...!!

Please Comment upon this...!!


If your new Big Idea doesn't scare the hell out of you, <br />it's probably not a "new Big Idea".
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
setting the textArea's document will do this for you
(DocumentFilter is the newer way)

here's a basic example (set to 20 characters, for testing)

Parth Bhatt
Ranch Hand

Joined: Oct 19, 2005
Posts: 58
Thanks a lot michael...!!

Will check out DocumentFilter later, this is exactley what i needed...!!

Thanks again...!! :-)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Which Listener to use for JTextArea