> I'd like to set the size of a JTextField and at the same time limit
> the number of characters that can be entered by the user to a higher
> number, i.e, the user can see 30 characters but can write 50.
PlainDocument doc = new PlainDocument() {
public void insertString(int offset, String str, AttributeSet a)
throws
BadLocationException {
if(offset >= 50) {
return;
}
int max = Math.min(50 - offset, str.length);
if(max < str.length) {
str = str.substring(0, max);
}
super.insertString(offset, str, a);
}
};
JTextField tf = new JTextField(doc, "", 30);
--
____________
http://reader.imagero.com the best java image reader.