當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。