本文整理汇总了Java中javax.swing.JFormattedTextField.AbstractFormatter方法的典型用法代码示例。如果您正苦于以下问题:Java JFormattedTextField.AbstractFormatter方法的具体用法?Java JFormattedTextField.AbstractFormatter怎么用?Java JFormattedTextField.AbstractFormatter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JFormattedTextField
的用法示例。
在下文中一共展示了JFormattedTextField.AbstractFormatter方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCalendarField
import javax.swing.JFormattedTextField; //导入方法依赖的package包/类
/**
* Returns the calendarField under the start of the selection, or -1 if
* there is no valid calendar field under the selection (or the spinner
* isn't editing dates.
*/
private int getCalendarField(JSpinner spinner)
{
JComponent editor = spinner.getEditor();
if( editor instanceof JSpinner.DateEditor )
{
JSpinner.DateEditor dateEditor = (JSpinner.DateEditor) editor;
JFormattedTextField ftf = dateEditor.getTextField();
int start = ftf.getSelectionStart();
JFormattedTextField.AbstractFormatter formatter = ftf.getFormatter();
if( formatter instanceof InternationalFormatter )
{
Format.Field[] fields = ((InternationalFormatter) formatter).getFields(start);
for( int counter = 0; counter < fields.length; counter++ )
{
if( fields[counter] instanceof DateFormat.Field )
{
int calendarField;
if( fields[counter] == DateFormat.Field.HOUR1 )
{
calendarField = Calendar.HOUR;
}
else
{
calendarField = ((DateFormat.Field) fields[counter]).getCalendarField();
}
if( calendarField != -1 )
{
return calendarField;
}
}
}
}
}
return -1;
}
示例2: getFormatter
import javax.swing.JFormattedTextField; //导入方法依赖的package包/类
/**
* Returns either the default formatter, display formatter, editor
* formatter or null formatter based on the state of the
* JFormattedTextField.
*
* @param source JFormattedTextField requesting
* JFormattedTextField.AbstractFormatter
* @return JFormattedTextField.AbstractFormatter to handle
* formatting duties.
*/
public JFormattedTextField.AbstractFormatter getFormatter(
JFormattedTextField source) {
JFormattedTextField.AbstractFormatter format = null;
if (source == null) {
return null;
}
Object value = source.getValue();
if (value == null) {
format = getNullFormatter();
}
if (format == null) {
if (source.hasFocus()) {
format = getEditFormatter();
}
else {
format = getDisplayFormatter();
}
if (format == null) {
format = getDefaultFormatter();
}
}
return format;
}
示例3: DefaultFormatterFactory
import javax.swing.JFormattedTextField; //导入方法依赖的package包/类
public DefaultFormatterFactory(
JFormattedTextField.AbstractFormatter defaultFormat,
JFormattedTextField.AbstractFormatter displayFormat,
JFormattedTextField.AbstractFormatter editFormat,
JFormattedTextField.AbstractFormatter nullFormat) {
this.defaultFormat = defaultFormat;
this.displayFormat = displayFormat;
this.editFormat = editFormat;
this.nullFormat = nullFormat;
}
示例4: DefaultFormatterFactory
import javax.swing.JFormattedTextField; //导入方法依赖的package包/类
/**
* Creates a DefaultFormatterFactory with the specified
* JFormattedTextField.AbstractFormatters.
*
* @param defaultFormat JFormattedTextField.AbstractFormatter to be used
* if a more specific
* JFormattedTextField.AbstractFormatter can not be
* found.
* @param displayFormat JFormattedTextField.AbstractFormatter to be used
* when the JFormattedTextField does not have focus.
* @param editFormat JFormattedTextField.AbstractFormatter to be used
* when the JFormattedTextField has focus.
*/
public DefaultFormatterFactory(
JFormattedTextField.AbstractFormatter defaultFormat,
JFormattedTextField.AbstractFormatter displayFormat,
JFormattedTextField.AbstractFormatter editFormat) {
this(defaultFormat, displayFormat, editFormat, null);
}
示例5: setNullFormatter
import javax.swing.JFormattedTextField; //导入方法依赖的package包/类
/**
* Sets the formatter to use if the value of the JFormattedTextField is
* null.
*
* @param atf JFormattedTextField.AbstractFormatter to use when
* the value of the JFormattedTextField is null.
*/
public void setNullFormatter(JFormattedTextField.AbstractFormatter atf) {
nullFormat = atf;
}
示例6: setDefaultFormatter
import javax.swing.JFormattedTextField; //导入方法依赖的package包/类
/**
* Sets the <code>JFormattedTextField.AbstractFormatter</code> to use as
* a last resort, eg in case a display, edit or null
* <code>JFormattedTextField.AbstractFormatter</code> has not been
* specified.
*
* @param atf JFormattedTextField.AbstractFormatter used if a more
* specific is not specified
*/
public void setDefaultFormatter(JFormattedTextField.AbstractFormatter atf){
defaultFormat = atf;
}
示例7: getDefaultFormatter
import javax.swing.JFormattedTextField; //导入方法依赖的package包/类
/**
* Returns the <code>JFormattedTextField.AbstractFormatter</code> to use
* as a last resort, eg in case a display, edit or null
* <code>JFormattedTextField.AbstractFormatter</code>
* has not been specified.
*
* @return JFormattedTextField.AbstractFormatter used if a more specific
* one is not specified.
*/
public JFormattedTextField.AbstractFormatter getDefaultFormatter() {
return defaultFormat;
}
示例8: getDisplayFormatter
import javax.swing.JFormattedTextField; //导入方法依赖的package包/类
/**
* Returns the <code>JFormattedTextField.AbstractFormatter</code> to use
* if the <code>JFormattedTextField</code> is not being edited and either
* the value is not-null, or the value is null and a null formatter has
* has not been specified.
*
* @return JFormattedTextField.AbstractFormatter to use when the
* JFormattedTextField does not have focus
*/
public JFormattedTextField.AbstractFormatter getDisplayFormatter() {
return displayFormat;
}
示例9: setEditFormatter
import javax.swing.JFormattedTextField; //导入方法依赖的package包/类
/**
* Sets the <code>JFormattedTextField.AbstractFormatter</code> to use if
* the <code>JFormattedTextField</code> is being edited and either
* the value is not-null, or the value is null and a null formatter has
* has not been specified.
*
* @param atf JFormattedTextField.AbstractFormatter to use when the
* component has focus
*/
public void setEditFormatter(JFormattedTextField.AbstractFormatter atf) {
editFormat = atf;
}
示例10: getNullFormatter
import javax.swing.JFormattedTextField; //导入方法依赖的package包/类
/**
* Returns the formatter to use if the value is null.
*
* @return JFormattedTextField.AbstractFormatter to use when the value is
* null
*/
public JFormattedTextField.AbstractFormatter getNullFormatter() {
return nullFormat;
}
示例11: DefaultFormatterFactory
import javax.swing.JFormattedTextField; //导入方法依赖的package包/类
/**
* Creates a <code>DefaultFormatterFactory</code> with the specified
* <code>JFormattedTextField.AbstractFormatter</code>.
*
* @param defaultFormat JFormattedTextField.AbstractFormatter to be used
* if a more specific
* JFormattedTextField.AbstractFormatter can not be
* found.
*/
public DefaultFormatterFactory(JFormattedTextField.
AbstractFormatter defaultFormat) {
this(defaultFormat, null);
}
示例12: getEditFormatter
import javax.swing.JFormattedTextField; //导入方法依赖的package包/类
/**
* Returns the <code>JFormattedTextField.AbstractFormatter</code> to use
* if the <code>JFormattedTextField</code> is being edited and either
* the value is not-null, or the value is null and a null formatter has
* has not been specified.
*
* @return JFormattedTextField.AbstractFormatter to use when the
* component has focus
*/
public JFormattedTextField.AbstractFormatter getEditFormatter() {
return editFormat;
}
示例13: DefaultFormatterFactory
import javax.swing.JFormattedTextField; //导入方法依赖的package包/类
/**
* Creates a <code>DefaultFormatterFactory</code> with the specified
* <code>JFormattedTextField.AbstractFormatter</code>s.
*
* @param defaultFormat JFormattedTextField.AbstractFormatter to be used
* if a more specific
* JFormattedTextField.AbstractFormatter can not be
* found.
* @param displayFormat JFormattedTextField.AbstractFormatter to be used
* when the JFormattedTextField does not have focus.
*/
public DefaultFormatterFactory(
JFormattedTextField.AbstractFormatter defaultFormat,
JFormattedTextField.AbstractFormatter displayFormat) {
this(defaultFormat, displayFormat, null);
}
示例14: setDisplayFormatter
import javax.swing.JFormattedTextField; //导入方法依赖的package包/类
/**
* Sets the <code>JFormattedTextField.AbstractFormatter</code> to use if
* the <code>JFormattedTextField</code> is not being edited and either
* the value is not-null, or the value is null and a null formatter has
* has not been specified.
*
* @param atf JFormattedTextField.AbstractFormatter to use when the
* JFormattedTextField does not have focus
*/
public void setDisplayFormatter(JFormattedTextField.AbstractFormatter atf){
displayFormat = atf;
}