本文整理匯總了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;
}
}
}
示例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;
}
}
}
示例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;
}
}
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
}
}
示例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;
}
}
示例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;
}
}
示例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;
}