* @throws CloneNotSupportedException if the Object's class doesn't support
* the {@link Cloneable} interface
*/
- protected Object clone ()
+ protected Object clone()
throws CloneNotSupportedException
{
// Clone this formatter.
- AbstractFormatter newFormatter = (AbstractFormatter)super.clone();
+ AbstractFormatter newFormatter = (AbstractFormatter) super.clone();
// And remove the association to the JFormattedTextField.
newFormatter.textField = null;
* @return <code>null</code>. Should be subclassed by formatters that want
* to install custom Actions on the JFormattedTextField.
*/
- protected Action[] getActions ()
+ protected Action[] getActions()
{
return null;
}
* @return <code>null</code>. Should be subclassed by formatters
* that want to restrict Document mutations.
*/
- protected DocumentFilter getDocumentFilter ()
+ protected DocumentFilter getDocumentFilter()
{
// Subclasses should override this if they want to install a
// DocumentFilter.
* @return the JFormattedTextField on which this formatter is currently
* installed
*/
- protected JFormattedTextField getFormattedTextField ()
+ protected JFormattedTextField getFormattedTextField()
{
return textField;
}
* @return <code>null</code>. Subclassed by formatters that want to restrict
* cursor location within the JFormattedTextField.
*/
- protected NavigationFilter getNavigationFilter ()
+ protected NavigationFilter getNavigationFilter()
{
// This should be subclassed if the formatter wants to install
// a NavigationFilter on the JFormattedTextField.
// Set the DocumentFilter for the field's Document.
if (doc instanceof AbstractDocument)
- ((AbstractDocument)doc).setDocumentFilter(getDocumentFilter());
+ ((AbstractDocument) doc).setDocumentFilter(getDocumentFilter());
// Set the NavigationFilter.
textField.setNavigationFilter(getNavigationFilter());
* This resets the DocumentFilter, NavigationFilter, and any additional
* Actions (returned by <code>getActions()</code>).
*/
- public void uninstall ()
+ public void uninstall()
{
// Set the DocumentFilter for the field's Document.
Document doc = textField.getDocument();
if (doc instanceof AbstractDocument)
- ((AbstractDocument)doc).setDocumentFilter(null);
+ ((AbstractDocument) doc).setDocumentFilter(null);
textField.setNavigationFilter(null);
// FIXME: Have to remove the Actions from getActions()
this.textField = null;
* Invoke this method when invalid values are entered. This forwards the
* call to the JFormattedTextField.
*/
- protected void invalidEdit ()
+ protected void invalidEdit()
{
textField.invalidEdit();
}
*
* @param valid the new state for the <code>editValid</code> property
*/
- protected void setEditValid (boolean valid)
+ protected void setEditValid(boolean valid)
{
textField.editValid = valid;
}
* @return an Object that <code>text</code> represented
* @throws ParseException if there is an error in the conversion
*/
- public abstract Object stringToValue (String text)
+ public abstract Object stringToValue(String text)
throws ParseException;
/**
* @return a String to be displayed
* @throws ParseException if there is an error in the conversion
*/
- public abstract String valueToString (Object value)
+ public abstract String valueToString(Object value)
throws ParseException;
}
*/
public abstract static class AbstractFormatterFactory
{
- public AbstractFormatterFactory ()
+ public AbstractFormatterFactory()
{
// Do nothing here.
}
- public abstract AbstractFormatter getFormatter (JFormattedTextField tf);
+ public abstract AbstractFormatter getFormatter(JFormattedTextField tf);
}
/** The possible focusLostBehavior options **/
* properly configure this text field to edit a particular type
* of value.
*/
- public JFormattedTextField ()
+ public JFormattedTextField()
{
this((AbstractFormatterFactory) null, null);
}
* @param format the Format that this JFormattedTextField should be able
* to handle
*/
- public JFormattedTextField (Format format)
+ public JFormattedTextField(Format format)
{
this ();
setFormatterFactory(getAppropriateFormatterFactory(format));
*
* @param formatter the formatter to use for this JFormattedTextField
*/
- public JFormattedTextField (AbstractFormatter formatter)
+ public JFormattedTextField(AbstractFormatter formatter)
{
- this(new DefaultFormatterFactory (formatter));
+ this(new DefaultFormatterFactory(formatter));
}
/**
*
* @param factory the formatter factory to use for this JFormattedTextField
*/
- public JFormattedTextField (AbstractFormatterFactory factory)
+ public JFormattedTextField(AbstractFormatterFactory factory)
{
setFormatterFactory(factory);
}
* @param factory the initial formatter factory for this JFormattedTextField
* @param value the initial value for the text field
*/
- public JFormattedTextField (AbstractFormatterFactory factory, Object value)
+ public JFormattedTextField(AbstractFormatterFactory factory, Object value)
{
setFormatterFactory(factory);
setValue(value);
*
* @param value the initial value for this JFormattedTextField
*/
- public JFormattedTextField (Object value)
+ public JFormattedTextField(Object value)
{
setValue(value);
}
* @return a DefaultFormatterFactory whose defaultFormatter is appropriate
* for the given Format.
*/
- private AbstractFormatterFactory getAppropriateFormatterFactory (Format format)
+ private AbstractFormatterFactory getAppropriateFormatterFactory(Format format)
{
AbstractFormatter newFormatter;
if (format instanceof DateFormat)
- newFormatter = new DateFormatter((DateFormat)format);
+ newFormatter = new DateFormatter((DateFormat) format);
else if (format instanceof NumberFormat)
- newFormatter = new NumberFormatter ((NumberFormat)format);
+ newFormatter = new NumberFormatter ((NumberFormat) format);
else
newFormatter = new InternationalFormatter(format);
*
* @throws ParseException if the formatter cannot format the current value
*/
- public void commitEdit ()
+ public void commitEdit()
throws ParseException
{
if (formatter == null)
*
* @return an array of Actions that this text field supports
*/
- public Action[] getActions ()
+ public Action[] getActions()
{
// FIXME: Add JFormattedTextField specific actions
// These are related to committing or cancelling edits.
* Returns the current formatter used for this JFormattedTextField.
* @return the current formatter used for this JFormattedTextField
*/
- public AbstractFormatter getFormatter ()
+ public AbstractFormatter getFormatter()
{
return formatter;
}
* JFormattedTextField.
* @return the factory currently used to generate formatters
*/
- public AbstractFormatterFactory getFormatterFactory ()
+ public AbstractFormatterFactory getFormatterFactory()
{
return formatterFactory;
}
- public String getUIClassID ()
+ public String getUIClassID()
{
return "FormattedTextFieldUI";
}
* valid edits and allows invalid input to be temporarily displayed.
* @return the last committed valid value
*/
- public Object getValue ()
+ public Object getValue()
{
return value;
}
* This method is used to provide feedback to the user when an invalid value
* is input during editing.
*/
- protected void invalidEdit ()
+ protected void invalidEdit()
{
UIManager.getLookAndFeel().provideErrorFeedback(this);
}
* managed by the current formatted.
* @return true if the value being edited is valid.
*/
- public boolean isEditValid ()
+ public boolean isEditValid()
{
return editValid;
}
*
* @param evt the FocusEvent
*/
- protected void processFocusEvent (FocusEvent evt)
+ protected void processFocusEvent(FocusEvent evt)
{
super.processFocusEvent(evt);
// Let the formatterFactory change the formatter for this text field
* @param formatter the AbstractFormatter to use for formatting the value for
* this JFormattedTextField
*/
- protected void setFormatter (AbstractFormatter formatter)
+ protected void setFormatter(AbstractFormatter formatter)
{
AbstractFormatter oldFormatter = null;
* @param factory the AbstractFormatterFactory that will be used to generate
* formatters for this JFormattedTextField
*/
- public void setFormatterFactory (AbstractFormatterFactory factory)
+ public void setFormatterFactory(AbstractFormatterFactory factory)
{
if (formatterFactory == factory)
return;
*
* @param newValue the value to be formatted and displayed
*/
- public void setValue (Object newValue)
+ public void setValue(Object newValue)
{
if (value == newValue)
return;