> how can i truncate the length can u give me any idea
> please ,
> i have written the document listener but i dont know
> how to truncate the length of the JTextFiled.
Get the contents with JTextField.getText(). If the string is too long, change it with JTextField.setText()...
You could also extend the JTextfield like so:
import java.awt.event.KeyEvent;
import javax.swing.JTextField;
public class RestrictedLengthTextField extends JTextField
{
// constructors here
public void processKeyEvent(KeyEvent evt) {
if(this.getText().length()>=10)
{
evt.consume();
}
super.processKeyEvent(evt);
}
}
Message was edited by:
ignignokt84