public abstract static class JFormattedTextField.AbstractFormatter extends Object implements Serializable
AbstractFormatter实例所使用的
JFormattedTextField处理从一个对象到字符串的转换,以及从一个字符串对象。
AbstractFormatters也可以执行编辑方针、政策或导航,或操纵
JFormattedTextField在它认为合适的任何方式来执行所需的政策。
一个AbstractFormatter一次只能在一个JFormattedTextField活跃。JFormattedTextField调用install何时准备使用它所遵循的uninstall完成时。子类,希望安装附加状态应重写install和消息超级合适。
子类必须重写转换方法stringToValue和valueToString。或者他们可以重写getActions,getNavigationFilter和getDocumentFilter限制在一个特定的方式JFormattedTextField。
子类,让JFormattedTextField是暂时无效的状态应该在适当的时候调用setEditValid。
| Constructor and Description |
|---|
AbstractFormatter() |
| Modifier and Type | Method and Description |
|---|---|
protected Object |
clone()
克隆
AbstractFormatter。
|
protected Action[] |
getActions()
子类并重写如果你希望提供一个自定义组
Actions。
|
protected DocumentFilter |
getDocumentFilter()
子类并重写如果你想限制什么可以输入提供一个
DocumentFilter。
|
protected JFormattedTextField |
getFormattedTextField()
返回当前安装的
AbstractFormatter
JFormattedTextField。
|
protected NavigationFilter |
getNavigationFilter()
子类和重写,如果您希望提供一个过滤器来限制用户可以导航到。
|
void |
install(JFormattedTextField ftf)
安装在一个特定的
JFormattedTextField
AbstractFormatter。
|
protected void |
invalidEdit()
当用户键入一个无效字符时,应该调用这个。
|
protected void |
setEditValid(boolean valid)
调用此更新的
JFormattedTextField的
editValid财产。
|
abstract Object |
stringToValue(String text)
解析
text返回任意对象。
|
void |
uninstall()
卸载
AbstractFormatter可以安装在任何状态
JFormattedTextField。
|
abstract String |
valueToString(Object value)
返回的字符串值显示为
value。
|
public void install(JFormattedTextField ftf)
AbstractFormatter在一个特定的
JFormattedTextField。这将调用
valueToString转换电流值从
JFormattedTextField为字符串。这将从
getActions安装
Actions,回来的
DocumentFilter
getDocumentFilter和
NavigationFilter返回到
JFormattedTextField
getNavigationFilter。
子类通常只需要重写这个如果他们希望在JFormattedTextField安装额外的听众。
如果在转换电流值为字符串的一ParseException,这将文本设置为空字符串,并标记JFormattedTextField处于无效状态。
虽然这是一个公共方法,这通常是唯一有用的JFormattedTextField subclassers。JFormattedTextField将调用此方法的值变化时,适当的时候,或其内部状态的变化。你只需要调用这个自己如果你是子类JFormattedTextField和安装/卸载AbstractFormatter在不同时间比JFormattedTextField呢。
ftf - JFormattedTextField格式,可从目前的jformattedtextfield卸载空指示。
public void uninstall()
AbstractFormatter可以安装在任何状态
JFormattedTextField。这将
DocumentFilter,
NavigationFilter和额外的
Actions安装在
JFormattedTextField。
public abstract Object stringToValue(String text) throws ParseException
text返回任意对象。有些程序可能返回null。
text字符串转换
ParseException -如果在转换中出现了一个错误
public abstract String valueToString(Object value) throws ParseException
value。
value价值转换
ParseException -如果在转换中出现了一个错误
protected JFormattedTextField getFormattedTextField()
AbstractFormatter
JFormattedTextField。
protected void invalidEdit()
protected void setEditValid(boolean valid)
JFormattedTextField的
editValid财产。如果你执行一个政策,
JFormattedTextField始终处于有效状态,你永远不需要调用这个。
valid的jformattedtextfield有效状态
protected Action[] getActions()
Actions。
install将安装在
JFormattedTextField的
ActionMap。
protected DocumentFilter getDocumentFilter()
DocumentFilter。
install将安装到
JFormattedTextField返回值。
protected NavigationFilter getNavigationFilter()
install将安装到
JFormattedTextField返回值。
protected Object clone() throws CloneNotSupportedException
AbstractFormatter。返回的实例未与
JFormattedTextField相关。
clone 方法重写,继承类
Object
CloneNotSupportedException -如果对象的类不支持
Cloneable接口。子类重写
clone方法也抛出该异常表示实例无法克隆。
Cloneable
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.