< prev index next >

src/java.desktop/share/classes/javax/swing/text/DefaultFormatterFactory.java

Print this page

        

*** 28,57 **** import java.text.ParseException; import javax.swing.JFormattedTextField; /** * An implementation of ! * <code>JFormattedTextField.AbstractFormatterFactory</code>. ! * <code>DefaultFormatterFactory</code> allows specifying a number of ! * different <code>JFormattedTextField.AbstractFormatter</code>s that are to * be used. * The most important one is the default one ! * (<code>setDefaultFormatter</code>). The default formatter will be used * if a more specific formatter could not be found. The following process * is used to determine the appropriate formatter to use. * <ol> * <li>Is the passed in value null? Use the null formatter. ! * <li>Does the <code>JFormattedTextField</code> have focus? Use the edit * formatter. * <li>Otherwise, use the display formatter. ! * <li>If a non-null <code>AbstractFormatter</code> has not been found, use * the default formatter. * </ol> * <p> * The following code shows how to configure a ! * <code>JFormattedTextField</code> with two ! * <code>JFormattedTextField.AbstractFormatter</code>s, one for display and * one for editing. * <pre> * JFormattedTextField.AbstractFormatter editFormatter = ...; * JFormattedTextField.AbstractFormatter displayFormatter = ...; * DefaultFormatterFactory factory = new DefaultFormatterFactory( --- 28,57 ---- import java.text.ParseException; import javax.swing.JFormattedTextField; /** * An implementation of ! * {@code JFormattedTextField.AbstractFormatterFactory}. ! * {@code DefaultFormatterFactory} allows specifying a number of ! * different {@code JFormattedTextField.AbstractFormatter}s that are to * be used. * The most important one is the default one ! * ({@code setDefaultFormatter}). The default formatter will be used * if a more specific formatter could not be found. The following process * is used to determine the appropriate formatter to use. * <ol> * <li>Is the passed in value null? Use the null formatter. ! * <li>Does the {@code JFormattedTextField} have focus? Use the edit * formatter. * <li>Otherwise, use the display formatter. ! * <li>If a non-null {@code AbstractFormatter} has not been found, use * the default formatter. * </ol> * <p> * The following code shows how to configure a ! * {@code JFormattedTextField} with two ! * {@code JFormattedTextField.AbstractFormatter}s, one for display and * one for editing. * <pre> * JFormattedTextField.AbstractFormatter editFormatter = ...; * JFormattedTextField.AbstractFormatter displayFormatter = ...; * DefaultFormatterFactory factory = new DefaultFormatterFactory(
*** 63,99 **** * Serialized objects of this class will not be compatible with * future Swing releases. The current serialization support is * appropriate for short term storage or RMI between applications running * the same version of Swing. As of 1.4, support for long term storage * of all JavaBeans&trade; ! * has been added to the <code>java.beans</code> package. * Please see {@link java.beans.XMLEncoder}. * * @see javax.swing.JFormattedTextField * * @since 1.4 */ @SuppressWarnings("serial") // Same-version serialization only public class DefaultFormatterFactory extends JFormattedTextField.AbstractFormatterFactory implements Serializable { /** ! * Default <code>AbstractFormatter</code> to use if a more specific one has * not been specified. */ private JFormattedTextField.AbstractFormatter defaultFormat; /** ! * <code>JFormattedTextField.AbstractFormatter</code> to use for display. */ private JFormattedTextField.AbstractFormatter displayFormat; /** ! * <code>JFormattedTextField.AbstractFormatter</code> to use for editing. */ private JFormattedTextField.AbstractFormatter editFormat; /** ! * <code>JFormattedTextField.AbstractFormatter</code> to use if the value * is null. */ private JFormattedTextField.AbstractFormatter nullFormat; --- 63,99 ---- * Serialized objects of this class will not be compatible with * future Swing releases. The current serialization support is * appropriate for short term storage or RMI between applications running * the same version of Swing. As of 1.4, support for long term storage * of all JavaBeans&trade; ! * has been added to the {@code java.beans} package. * Please see {@link java.beans.XMLEncoder}. * * @see javax.swing.JFormattedTextField * * @since 1.4 */ @SuppressWarnings("serial") // Same-version serialization only public class DefaultFormatterFactory extends JFormattedTextField.AbstractFormatterFactory implements Serializable { /** ! * Default {@code AbstractFormatter} to use if a more specific one has * not been specified. */ private JFormattedTextField.AbstractFormatter defaultFormat; /** ! * {@code JFormattedTextField.AbstractFormatter} to use for display. */ private JFormattedTextField.AbstractFormatter displayFormat; /** ! * {@code JFormattedTextField.AbstractFormatter} to use for editing. */ private JFormattedTextField.AbstractFormatter editFormat; /** ! * {@code JFormattedTextField.AbstractFormatter} to use if the value * is null. */ private JFormattedTextField.AbstractFormatter nullFormat;
*** 102,113 **** */ public DefaultFormatterFactory() { } /** ! * 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. --- 102,113 ---- */ public DefaultFormatterFactory() { } /** ! * Creates a {@code DefaultFormatterFactory} with the specified ! * {@code JFormattedTextField.AbstractFormatter}. * * @param defaultFormat JFormattedTextField.AbstractFormatter to be used * if a more specific * JFormattedTextField.AbstractFormatter can not be * found.
*** 116,127 **** AbstractFormatter defaultFormat) { this(defaultFormat, null); } /** ! * 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. --- 116,127 ---- AbstractFormatter defaultFormat) { this(defaultFormat, null); } /** ! * Creates a {@code DefaultFormatterFactory} with the specified ! * {@code JFormattedTextField.AbstractFormatter}s. * * @param defaultFormat JFormattedTextField.AbstractFormatter to be used * if a more specific * JFormattedTextField.AbstractFormatter can not be * found.
*** 179,216 **** this.editFormat = editFormat; this.nullFormat = nullFormat; } /** ! * 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; } /** ! * 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; } /** ! * 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 --- 179,216 ---- this.editFormat = editFormat; this.nullFormat = nullFormat; } /** ! * Sets the {@code JFormattedTextField.AbstractFormatter} to use as * a last resort, eg in case a display, edit or null ! * {@code JFormattedTextField.AbstractFormatter} has not been * specified. * * @param atf JFormattedTextField.AbstractFormatter used if a more * specific is not specified */ public void setDefaultFormatter(JFormattedTextField.AbstractFormatter atf){ defaultFormat = atf; } /** ! * Returns the {@code JFormattedTextField.AbstractFormatter} to use * as a last resort, eg in case a display, edit or null ! * {@code JFormattedTextField.AbstractFormatter} * has not been specified. * * @return JFormattedTextField.AbstractFormatter used if a more specific * one is not specified. */ public JFormattedTextField.AbstractFormatter getDefaultFormatter() { return defaultFormat; } /** ! * Sets the {@code JFormattedTextField.AbstractFormatter} to use if ! * the {@code JFormattedTextField} 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
*** 218,229 **** public void setDisplayFormatter(JFormattedTextField.AbstractFormatter atf){ displayFormat = atf; } /** ! * 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 --- 218,229 ---- public void setDisplayFormatter(JFormattedTextField.AbstractFormatter atf){ displayFormat = atf; } /** ! * Returns the {@code JFormattedTextField.AbstractFormatter} to use ! * if the {@code JFormattedTextField} 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
*** 231,242 **** public JFormattedTextField.AbstractFormatter getDisplayFormatter() { return displayFormat; } /** ! * 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 --- 231,242 ---- public JFormattedTextField.AbstractFormatter getDisplayFormatter() { return displayFormat; } /** ! * Sets the {@code JFormattedTextField.AbstractFormatter} to use if ! * the {@code JFormattedTextField} 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
*** 244,255 **** public void setEditFormatter(JFormattedTextField.AbstractFormatter atf) { editFormat = atf; } /** ! * 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 --- 244,255 ---- public void setEditFormatter(JFormattedTextField.AbstractFormatter atf) { editFormat = atf; } /** ! * Returns the {@code JFormattedTextField.AbstractFormatter} to use ! * if the {@code JFormattedTextField} 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
< prev index next >