RmiClient  1.0
 Alle Klassen Namensbereiche Dateien Funktionen Variablen
TextLengthDocument.java
gehe zur Dokumentation dieser Datei
1 package main;
2 
3 import javax.swing.text.PlainDocument;
4 import javax.swing.text.*;
5 
11 public class TextLengthDocument extends PlainDocument {
12 
13  private static final long serialVersionUID = 1L;
14 
15  private int limit;
16 
23  public TextLengthDocument(int limit) {
24  super();
25  this.limit = limit;
26  }
27 
28  public void insertString(int offset, String str, AttributeSet attr)
29  throws BadLocationException {
30  if (str == null)
31  return;
32 
33  if ((getLength() + str.length()) <= limit) {
34  super.insertString(offset, str, attr);
35  }
36  }
37 }