public abstract static class JFormattedTextField.AbstractFormatter extends Object implements Serializable
AbstractFormatter
实例所使用的
JFormattedTextField
处理从一个对象到字符串的转换,以及从一个字符串对象。
AbstractFormatter
s也可以执行编辑方针、政策或导航,或操纵
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()
子类并重写如果你希望提供一个自定义组
Action s。
|
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
安装
Action
s,回来的
DocumentFilter
getDocumentFilter
和
NavigationFilter
返回到
JFormattedTextField
getNavigationFilter
。
子类通常只需要重写这个如果他们希望在JFormattedTextField
安装额外的听众。
如果在转换电流值为字符串的一ParseException
,这将文本设置为空字符串,并标记JFormattedTextField
处于无效状态。
虽然这是一个公共方法,这通常是唯一有用的JFormattedTextField
subclassers。JFormattedTextField
将调用此方法的值变化时,适当的时候,或其内部状态的变化。你只需要调用这个自己如果你是子类JFormattedTextField
和安装/卸载AbstractFormatter
在不同时间比JFormattedTextField
呢。
ftf
- JFormattedTextField格式,可从目前的jformattedtextfield卸载空指示。
public void uninstall()
AbstractFormatter
可以安装在任何状态
JFormattedTextField
。这将
DocumentFilter
,
NavigationFilter
和额外的
Action
s安装在
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()
Action
s。
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.