X-Git-Url: https://gitweb.fperrin.net/?p=GpsPrune.git;a=blobdiff_plain;f=src%2Ftim%2Fprune%2Fload%2FOneCharDocument.java;fp=src%2Ftim%2Fprune%2Fload%2FOneCharDocument.java;h=9868984f1d6b66ed3dc1eb3cbfbc0dc611b15e57;hp=0000000000000000000000000000000000000000;hb=ce6f2161b8596f7018d6a76bff79bc9e571f35fd;hpb=2d8cb72e84d5cc1089ce77baf1e34ea3ea2f8465 diff --git a/src/tim/prune/load/OneCharDocument.java b/src/tim/prune/load/OneCharDocument.java new file mode 100644 index 0000000..9868984 --- /dev/null +++ b/src/tim/prune/load/OneCharDocument.java @@ -0,0 +1,21 @@ +package tim.prune.load; + +import javax.swing.text.AttributeSet; +import javax.swing.text.BadLocationException; +import javax.swing.text.PlainDocument; + +/** + * Document class to restrict text input to single character + * for selection of custom delimiter + */ +public class OneCharDocument extends PlainDocument +{ + public void insertString(int offs, String str, AttributeSet a) + throws BadLocationException + { + //This rejects the insertion if it would make + //the contents too long. + if ((getLength() + str.length()) <= 1) + super.insertString(offs, str, a); + } +}