]> gitweb.fperrin.net Git - GpsPrune.git/blob - tim/prune/load/OneCharDocument.java
9868984f1d6b66ed3dc1eb3cbfbc0dc611b15e57
[GpsPrune.git] / tim / prune / load / OneCharDocument.java
1 package tim.prune.load;
2
3 import javax.swing.text.AttributeSet;
4 import javax.swing.text.BadLocationException;
5 import javax.swing.text.PlainDocument;
6
7 /**
8  * Document class to restrict text input to single character
9  * for selection of custom delimiter
10  */
11 public class OneCharDocument extends PlainDocument
12 {
13         public void insertString(int offs, String str, AttributeSet a)
14                 throws BadLocationException
15         {
16                 //This rejects the insertion if it would make
17                 //the contents too long.
18                 if ((getLength() + str.length()) <= 1)
19                         super.insertString(offs, str, a);
20         }
21 }