本文整理匯總了Java中javax.swing.JFormattedTextField.hasFocus方法的典型用法代碼示例。如果您正苦於以下問題:Java JFormattedTextField.hasFocus方法的具體用法?Java JFormattedTextField.hasFocus怎麽用?Java JFormattedTextField.hasFocus使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.JFormattedTextField
的用法示例。
在下文中一共展示了JFormattedTextField.hasFocus方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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;
}