File: OneCharDocument.java

package info (click to toggle)
gpsprune 17-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 3,984 kB
  • ctags: 5,218
  • sloc: java: 39,403; sh: 25; makefile: 17; python: 15
file content (21 lines) | stat: -rw-r--r-- 563 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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);
	}
}