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


Java JFormattedTextField.getValue方法代码示例

本文整理汇总了Java中javax.swing.JFormattedTextField.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java JFormattedTextField.getValue方法的具体用法?Java JFormattedTextField.getValue怎么用?Java JFormattedTextField.getValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JFormattedTextField的用法示例。


在下文中一共展示了JFormattedTextField.getValue方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCellEditorValue

import javax.swing.JFormattedTextField; //导入方法依赖的package包/类
public Object getCellEditorValue() {
    JFormattedTextField ftf = (JFormattedTextField) getComponent();
    Object o = ftf.getValue();
    if (o instanceof Integer) {
        return o;
    } else if (o instanceof Number) {
        return new Integer(((Number) o).intValue());
    } else {
        if (DEBUG) {
            System.out.println("getCellEditorValue: o isn't a Number");
        }
        try {
            return integerFormat.parseObject(o.toString());
        } catch (ParseException exc) {
            System.err.println("getCellEditorValue: can't parse o: " + o);
            return null;
        }
    }
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:20,代码来源:IntegerEditor.java

示例2: getCellEditorValue

import javax.swing.JFormattedTextField; //导入方法依赖的package包/类
@Override
public Object getCellEditorValue() {
    JFormattedTextField ftf = (JFormattedTextField) getComponent();
    Object o = ftf.getValue();
    if (o instanceof Integer) {
        return o;
    } else if (o instanceof Number) {
        return new Integer(((Number) o).intValue());
    } else {
        try {
            return integerFormat.parseObject(o.toString());
        } catch (ParseException ex) {
            LOGGER.log(Level.FINE, "getCellEditorValue: can't parse {0}", o);
            return null;
        }
    }
}
 
开发者ID:takun2s,项目名称:smile_1.5.0_java7,代码行数:18,代码来源:IntegerCellEditor.java

示例3: getCellEditorValue

import javax.swing.JFormattedTextField; //导入方法依赖的package包/类
@Override
public Object getCellEditorValue() {
    JFormattedTextField ftf = (JFormattedTextField) getComponent();
    Object o = ftf.getValue();
    if (o instanceof Double) {
        return o;
    } else if (o instanceof Number) {
        return new Double(((Number) o).doubleValue());
    } else {
        try {
            return doubleFormat.parseObject(o.toString());
        } catch (ParseException ex) {
            LOGGER.log(Level.FINE, "getCellEditorValue: can't parse {0}", o);
            return null;
        }
    }
}
 
开发者ID:takun2s,项目名称:smile_1.5.0_java7,代码行数:18,代码来源:DoubleCellEditor.java

示例4: 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

示例5: stringToValue

import javax.swing.JFormattedTextField; //导入方法依赖的package包/类
@Override
public Object stringToValue (String string)
        throws ParseException
{
    try {
        JFormattedTextField ftf = getFormattedTextField();
        Object value = ftf.getValue();

        if (value instanceof Integer) {
            return Integer.valueOf(string, 16);
        } else if (value instanceof Long) {
            return Long.valueOf(string, 16);
        } else {
            throw new IllegalArgumentException(
                    "Illegal Number class for HexaFormatter " + value.getClass());
        }
    } catch (NumberFormatException ex) {
        throw new ParseException(string, 0);
    }
}
 
开发者ID:Audiveris,项目名称:audiveris,代码行数:21,代码来源:LHexaSpinner.java

示例6: getFormatter

import javax.swing.JFormattedTextField; //导入方法依赖的package包/类
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:javalovercn,项目名称:j2se_for_android,代码行数:26,代码来源:DefaultFormatterFactory.java

示例7: getFormatter

import javax.swing.JFormattedTextField; //导入方法依赖的package包/类
/**
 * Returns the appropriate formatter based on the state of
 * <code>tf</code>. If <code>tf<code> is null we return null, otherwise
 * we return one of the following:
 * 1. Returns <code>nullFormatter</code> if <code>tf.getValue()</code> is
 * null and <code>nullFormatter</code> is not.
 * 2. Returns <code>editFormatter</code> if <code>tf.hasFocus()</code> is
 * true and <code>editFormatter</code> is not null.
 * 3. Returns <code>displayFormatter</code> if <code>tf.hasFocus()</code> is
 * false and <code>displayFormatter</code> is not null.
 * 4. Otherwise returns <code>defaultFormatter</code>.
 */
public AbstractFormatter getFormatter(JFormattedTextField tf)
{
  if (tf == null)
    return null;

  if (tf.getValue() == null && nullFormatter != null)
    return nullFormatter;

  if (tf.hasFocus() && editFormatter != null)
    return editFormatter;

  if (!tf.hasFocus() && displayFormatter != null)
    return displayFormatter;

  return defaultFormatter;
}
 
开发者ID:vilie,项目名称:javify,代码行数:29,代码来源:DefaultFormatterFactory.java

示例8: getTextFieldDoubleValue

import javax.swing.JFormattedTextField; //导入方法依赖的package包/类
/**
 * Reads the double value of a textfield and returns it
 * 
 * @param tf
 *            textfield
 * @return double value
 */
public static double getTextFieldDoubleValue(JFormattedTextField tf) {
	Double d = 0.0;
	int i = 0;
	if (tf.getValue().getClass() == Double.class || tf.getValue().getClass() == double.class) {
		d = (double) tf.getValue();
	} else if (tf.getValue().getClass() == Integer.class || tf.getValue().getClass() == int.class) {
		i = (Integer) tf.getValue();
		d = (double) i;
	} else if (tf.getValue().getClass() == long.class || tf.getValue().getClass() == Long.class) {
		d = ((Long) tf.getValue()).doubleValue();
	}
	if (tf.getValue().getClass() == String.class) {
		try {
			String s = (String) tf.getValue();
			d = Double.valueOf(s);
		} catch (Exception e) {
		}
	}
	return d;
}
 
开发者ID:noah95,项目名称:ezrlc,代码行数:28,代码来源:UIUtil.java

示例9: getCellEditorValue

import javax.swing.JFormattedTextField; //导入方法依赖的package包/类
@Override
public Object getCellEditorValue() {
    JFormattedTextField ftf = (JFormattedTextField) getComponent();
    Object o = ftf.getValue();
    if (o instanceof Date) {
        return o;
    } else {
        try {
            return dateFormat.parseObject(o.toString());
        } catch (ParseException ex) {
            LOGGER.log(Level.FINE, "getCellEditorValue: can't parse {0}", o);
            return null;
        }
    }
}
 
开发者ID:takun2s,项目名称:smile_1.5.0_java7,代码行数:16,代码来源:DateCellEditor.java

示例10: getCellEditorValue

import javax.swing.JFormattedTextField; //导入方法依赖的package包/类
@Override
public Object getCellEditorValue() {
    JFormattedTextField ftf = (JFormattedTextField) getComponent();
    Object o = ftf.getValue();
    if (o instanceof int[]) {
        return o;
    } else {
        LOGGER.log(Level.FINE, "getCellEditorValue: can't parse {0}", o);
        return null;
    }
}
 
开发者ID:takun2s,项目名称:smile_1.5.0_java7,代码行数:12,代码来源:IntegerArrayCellEditor.java

示例11: getCellEditorValue

import javax.swing.JFormattedTextField; //导入方法依赖的package包/类
@Override
public Object getCellEditorValue() {
    JFormattedTextField ftf = (JFormattedTextField) getComponent();
    Object o = ftf.getValue();
    if (o instanceof double[]) {
        return o;
    } else {
        LOGGER.log(Level.FINE, "getCellEditorValue: can't parse o{0}", o);
        return null;
    }
}
 
开发者ID:takun2s,项目名称:smile_1.5.0_java7,代码行数:12,代码来源:DoubleArrayCellEditor.java

示例12: stringToValue

import javax.swing.JFormattedTextField; //导入方法依赖的package包/类
/**
 * Converts the passed in String into an instance of
 * <code>getValueClass</code> by way of the constructor that takes a String
 * argument. If <code>getValueClass</code> returns null, the Class of the
 * current value in the <code>JFormattedTextField</code> will be used. If
 * this is null, a String will be returned. If the constructor thows an
 * exception, a <code>ParseException</code> will be thrown. If there is no
 * single argument String constructor, <code>string</code> will be returned.
 * 
 * @throws ParseException
 *             if there is an error in the conversion
 * @param string
 *            String to convert
 * @return Object representation of text
 */
public Object stringToValue(String string) throws ParseException {
	Class<?> vc = getValueClass();
	JFormattedTextField ftf = getFormattedTextField();

	if (vc == null && ftf != null) {
		Object value = ftf.getValue();

		if (value != null) {
			vc = value.getClass();
		}
	}
	if (vc != null) {
		Constructor cons;

		try {
			cons = vc.getConstructor(new Class[] { String.class });

		} catch (NoSuchMethodException nsme) {
			cons = null;
		}

		if (cons != null) {
			try {
				return cons.newInstance(new Object[] { string });
			} catch (Throwable ex) {
				throw new ParseException("Error creating instance", 0);
			}
		}
	}
	return string;
}
 
开发者ID:javalovercn,项目名称:j2se_for_android,代码行数:47,代码来源:DefaultFormatter.java


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