com.internationalnetwork.gui
Class JTextFieldLimit

Object
  extended by javax.swing.text.AbstractDocument
      extended by javax.swing.text.PlainDocument
          extended by com.internationalnetwork.gui.JTextFieldLimit
All Implemented Interfaces:
java.io.Serializable, javax.swing.text.Document

public class JTextFieldLimit
extends javax.swing.text.PlainDocument

The JTextFieldLimit class is used to restrict the maximum length of user input from the JTextField and JPasswordField methods in JFC/Swing.

Usage example:

  import com.internationalnetwork.gui.JTextFieldLimit;
  import java.awt.*;
  import javax.swing.*;

  public class tswing extends JApplet{
    JTextField textfield1;
    JLabel label1;

    public void init() {
      getContentPane().setLayout(new FlowLayout());
      label1 = new JLabel("max 10 chars");
      textfield1 = new JTextField(15);
      getContentPane().add(label1);
      getContentPane().add(textfield1);
      textfield1.setDocument(new JTextFieldLimit(10));
    }
  }

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.text.AbstractDocument
javax.swing.text.AbstractDocument.AbstractElement, javax.swing.text.AbstractDocument.AttributeContext, javax.swing.text.AbstractDocument.BranchElement, javax.swing.text.AbstractDocument.Content, javax.swing.text.AbstractDocument.DefaultDocumentEvent, javax.swing.text.AbstractDocument.ElementEdit, javax.swing.text.AbstractDocument.LeafElement
 
Field Summary
static String VERSION
          Version number of this Package (read-only).
 
Fields inherited from class javax.swing.text.PlainDocument
lineLimitAttribute, tabSizeAttribute
 
Fields inherited from class javax.swing.text.AbstractDocument
BAD_LOCATION, BidiElementName, ContentElementName, ElementNameAttribute, listenerList, ParagraphElementName, SectionElementName
 
Fields inherited from interface javax.swing.text.Document
StreamDescriptionProperty, TitleProperty
 
Method Summary
 void insertString(int offset, String str, javax.swing.text.AttributeSet attr)
          Extension, expected by the JTextField and JPasswordField methods in JFC/Swing.
 
Methods inherited from class javax.swing.text.PlainDocument
createDefaultRoot, getDefaultRootElement, getParagraphElement, insertUpdate, removeUpdate
 
Methods inherited from class javax.swing.text.AbstractDocument
addDocumentListener, addUndoableEditListener, createBranchElement, createLeafElement, createPosition, dump, fireChangedUpdate, fireInsertUpdate, fireRemoveUpdate, fireUndoableEditUpdate, getAsynchronousLoadPriority, getAttributeContext, getBidiRootElement, getContent, getCurrentWriter, getDocumentFilter, getDocumentListeners, getDocumentProperties, getEndPosition, getLength, getListeners, getProperty, getRootElements, getStartPosition, getText, getText, getUndoableEditListeners, postRemoveUpdate, putProperty, readLock, readUnlock, remove, removeDocumentListener, removeUndoableEditListener, render, replace, setAsynchronousLoadPriority, setDocumentFilter, setDocumentProperties, writeLock, writeUnlock
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERSION

public static final String VERSION
Version number of this Package (read-only).

See Also:
Constant Field Values
Method Detail

insertString

public void insertString(int offset,
                         String str,
                         javax.swing.text.AttributeSet attr)
                  throws javax.swing.text.BadLocationException
Extension, expected by the JTextField and JPasswordField methods in JFC/Swing.

Specified by:
insertString in interface javax.swing.text.Document
Overrides:
insertString in class javax.swing.text.PlainDocument
Throws:
javax.swing.text.BadLocationException