当前位置: 首页>>代码示例>>Java>>正文


Java JFormattedTextField.AbstractFormatter方法代码示例

本文整理汇总了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;
}
 
开发者ID:equella,项目名称:Equella,代码行数:45,代码来源:FlatterSpinnerUI.java

示例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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:36,代码来源:DefaultFormatterFactory.java

示例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;
}
 
开发者ID:javalovercn,项目名称:j2se_for_android,代码行数:11,代码来源:DefaultFormatterFactory.java

示例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);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:DefaultFormatterFactory.java

示例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;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:11,代码来源:DefaultFormatterFactory.java

示例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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:13,代码来源:DefaultFormatterFactory.java

示例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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:13,代码来源:DefaultFormatterFactory.java

示例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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:13,代码来源:DefaultFormatterFactory.java

示例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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:13,代码来源:DefaultFormatterFactory.java

示例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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:10,代码来源:DefaultFormatterFactory.java

示例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);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:14,代码来源:DefaultFormatterFactory.java

示例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;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:13,代码来源:DefaultFormatterFactory.java

示例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);
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:17,代码来源:DefaultFormatterFactory.java

示例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;
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:13,代码来源:DefaultFormatterFactory.java


注:本文中的javax.swing.JFormattedTextField.AbstractFormatter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。