package myuml;


import javax.swing.text.*;



/**
 * <p>Title: Hola a todos</p>
 *
 * <p>Description: este es el tutorial hola a todos</p>
 *
 * <p>Copyright: Copyright (c) 2005</p>
 *
 * <p>Company: Mi empresa</p>
 *
 * @author Mi nombre
 * @version 1.0
 */


public class FixedLengthPlainDocument extends PlainDocument
{

    private int maxLength;

    public FixedLengthPlainDocument(int maxLength) {
              this.maxLength = maxLength;
    }

    public void insertString(int offset, String str,AttributeSet a)
            throws BadLocationException {
            if(getLength() + str.length() > maxLength) {

                    Toolkit.getDefaultToolkit().beep();
            }
            else {
                     super.insertString(offset, str, a);

            }
    }

}


