|
Groovy Documentation | |||||||
| FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectjavax.swing.text.DocumentFilter
com.wordpress.tipsforjava.swing.text.ChainedDocumentFilter
com.wordpress.tipsforjava.swing.text.SizeDocumentFilter
public class SizeDocumentFilter extends ChainedDocumentFilter
A DocumentFilter that allows you to control the maximum number of characters that can be added to the Document. When the Document is full you can optionally tab to the next component to speed data entry. This class can also be used as a generic size filter for JTextFields. In this case when a size of 0 is speicifed for the size of the Document the getColumns() method of JTextField will be used to determine the size restriction.
| Field Summary | |
|---|---|
private boolean |
autoTab
|
private int |
size
|
| Fields inherited from class ChainedDocumentFilter | |
|---|---|
| filter |
| Constructor Summary | |
SizeDocumentFilter()
Generic constructor for use with JTextFields only. |
|
SizeDocumentFilter(int size)
Constructor to set the size for this filter |
|
SizeDocumentFilter(int size, DocumentFilter filter)
Constructor to set the size for this filter as well as provide additional filtering |
|
| Method Summary | |
|---|---|
private int
|
getAllowedSize(FilterBypass fb)
When a size isn't specified then we assume the desired size can be obtained from the associated text field. |
boolean
|
getAutoTab()
Get the auto tab property |
private int
|
getColumns(FilterBypass fb)
|
int
|
getSize()
Get the maximum size for any Document using this filter |
protected void
|
handleAutoTab(int possibleSize, int allowedSize, FilterBypass fb)
|
void
|
insertString(FilterBypass fb, int offs, String str, AttributeSet a)
Make sure the insertion of text will not cause the Document to exceed its size limit. |
void
|
replace(FilterBypass fb, int offs, int length, String str, AttributeSet a)
Make sure the replacement of text will not cause the Document to exceed its size limit. |
void
|
setAutoTab(boolean autoTab)
Set the auto tab property |
void
|
setSize(int size)
Set maximum size for a Document using this filter. |
| Methods inherited from class ChainedDocumentFilter | |
|---|---|
| getFilter, insertString, installFilter, provideErrorFeedback, remove, replace, setFilter, uninstallFilter |
| Methods inherited from class DocumentFilter | |
|---|---|
| replace, remove, insertString, wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll |
| Field Detail |
|---|
private boolean autoTab
private int size
| Constructor Detail |
|---|
public SizeDocumentFilter()
public SizeDocumentFilter(int size)
size - maximum number of characters to be added to the Document
public SizeDocumentFilter(int size, DocumentFilter filter)
size - maximum number of characters to be added to the Documentfilter - another DocumentFilter to invoke
| Method Detail |
|---|
private int getAllowedSize(FilterBypass fb)
public boolean getAutoTab()
private int getColumns(FilterBypass fb)
public int getSize()
protected void handleAutoTab(int possibleSize, int allowedSize, FilterBypass fb)
de public public void insertString(FilterBypass fb, int offs, String str, AttributeSet a)
de public public void replace(FilterBypass fb, int offs, int length, String str, AttributeSet a)
public void setAutoTab(boolean autoTab)
autoTab - the default is true
public void setSize(int size)
size - the maximum number of character allowed in the Document
Groovy Documentation