JTextArea

HI FriendsI want to limit the number of characters in JTextArea.Is their is any way to do this .Thanks -Sunny Jain-
[150 byte] By [sunnyjaina] at [2007-11-27 8:14:51]
# 1

hope this help... it limits the character being inputted, just changed the value 10

public void keyTyped(KeyEvent e){

if (getText().length() >= 10) e.consume();

}

public void keyPressed(KeyEvent e) {

// do nothing

}

public void keyReleased(KeyEvent e) {

// do nothing

}

Yannixa at 2007-7-12 19:59:28 > top of Java-index,Desktop,Core GUI APIs...
# 2
The other way you can implement a subclass of DocumentFilter, and assign to the TextField.checking of num of characters can be do inside the Filter.
mcstevenjpa at 2007-7-12 19:59:28 > top of Java-index,Desktop,Core GUI APIs...
# 3
The tutorial contains an example that does exactly what you need.DocumentSizeFilter http://java.sun.com/docs/books/tutorial/uiswing/components/generaltext.html#filter
Rodney_McKaya at 2007-7-12 19:59:28 > top of Java-index,Desktop,Core GUI APIs...