/** * Checks and returns custom formats on the editor, if any. * * @param editor the editor to check * @return the custom formats uses in the editor or null if it had * used defaults as defined in the datepicker properties */ private DateFormat[] getCustomFormats(JFormattedTextField editor) { DateFormat[] formats = null; if (editor != null) { AbstractFormatterFactory factory = editor.getFormatterFactory(); if (factory != null) { AbstractFormatter formatter = factory.getFormatter(editor); // fix for #1144: classCastException for custom formatters // PENDING JW: revisit for #1138 if ((formatter instanceof DatePickerFormatter) && !(formatter instanceof UIResource)) { // if (!(formatter instanceof DatePickerFormatterUIResource)) { formats = ((DatePickerFormatter) formatter).getFormats(); } } } return formats; }
/** * Returns an array of the formats used by the installed formatter * if it is a subclass of <code>JXDatePickerFormatter<code>. * <code>javax.swing.JFormattedTextField.AbstractFormatter</code> * and <code>javax.swing.text.DefaultFormatter</code> do not have * support for accessing the formats used. * * @return array of formats guaranteed to be not null, but might be empty. */ public DateFormat[] getFormats() { // Dig this out from the factory, if possible, otherwise return null. AbstractFormatterFactory factory = _dateField.getFormatterFactory(); if (factory != null) { AbstractFormatter formatter = factory.getFormatter(_dateField); if (formatter instanceof DatePickerFormatter) { return ((DatePickerFormatter) formatter).getFormats(); } } return EMPTY_DATE_FORMATS; }
public void setFormatterFactory(final AbstractFormatterFactory formatter) { if (textComponent instanceof JFormattedTextField) { ((JFormattedTextField)textComponent).setFormatterFactory(formatter); } }
public AbstractFormatterFactory getFormatterFactory() { if (textComponent instanceof JFormattedTextField) { return ((JFormattedTextField)textComponent).getFormatterFactory(); } else { return null; } }
/** * Checks and returns custom formats on the editor, if any. * * @param editor the editor to check * @return the custom formats uses in the editor or null if it had * used defaults as defined in the datepicker properties */ private DateFormat[] getCustomFormats(JFormattedTextField editor) { DateFormat[] formats = null; if (editor != null) { AbstractFormatterFactory factory = editor.getFormatterFactory(); if (factory != null) { AbstractFormatter formatter = factory.getFormatter(editor); if (!(formatter instanceof DatePickerFormatterUIResource)) { formats = ((DatePickerFormatter) formatter).getFormats(); } } } return formats; }
/** * Returns an array of the formats used by the installed formatter * if it is a subclass of <code>JXDatePickerFormatter<code>. * <code>javax.swing.JFormattedTextField.AbstractFormatter</code> * and <code>javax.swing.text.DefaultFormatter</code> do not have * support for accessing the formats used. * * @return array of formats or null if unavailable. */ public DateFormat[] getFormats() { // Dig this out from the factory, if possible, otherwise return null. AbstractFormatterFactory factory = _dateField.getFormatterFactory(); if (factory != null) { AbstractFormatter formatter = factory.getFormatter(_dateField); if (formatter instanceof JXDatePickerFormatter) { return ((JXDatePickerFormatter)formatter).getFormats(); } } return null; }
@Override public AbstractFormatterFactory getFormatterFactory() { return m_factory; }
@Override public AbstractFormatterFactory getFormatterFactory() { return null; }
private void configureComponents() { dateEchoField.setEditable(false); AbstractFormatter formatter = new DateFormatter(DateFormat.getDateTimeInstance()); AbstractFormatterFactory tf = new DefaultFormatterFactory(formatter); dateEchoField.setFormatterFactory(tf); }
/** * Convenience method for creating a formatter factory with a * {@code ScalableNumberFormatter} and a Java-style DecimalFormat. */ public static AbstractFormatterFactory createFormatterFactory(double min, double max, double multiplier, boolean allowsNullValue) { JavaNumberFormatter formatter = new JavaNumberFormatter(min, max, multiplier, allowsNullValue, null); return new DefaultFormatterFactory(formatter); }
/** * Convenience method for creating a formatter factory with a * {@code ScalableNumberFormatter} and a Java-style DecimalFormat. */ public static AbstractFormatterFactory createFormatterFactory(double min, double max, double multiplier, boolean allowsNullValue, @Nullable String unit) { JavaNumberFormatter formatter = new JavaNumberFormatter(min, max, multiplier, allowsNullValue, unit); return new DefaultFormatterFactory(formatter); }
public static AbstractFormatterFactory createFormatterFactory(boolean allowsNullValue) { return new DefaultFormatterFactory(new FontFormatter(allowsNullValue)); }
public static AbstractFormatterFactory createFormatterFactory() { return createFormatterFactory(Format.RGB_INTEGER_SHORT, true, true); }
public static AbstractFormatterFactory createFormatterFactory(Format outputFormat, boolean allowsNullValue, boolean isAdaptive) { return new DefaultFormatterFactory(new ColorFormatter(outputFormat, allowsNullValue, isAdaptive)); }
protected JComponent createControl(Map context) { return getComponentFactory().createFormattedTextField( (AbstractFormatterFactory)context.get(FORMATTER_FACTORY_KEY)); }
public Binding createBoundFormattedTextField(String formProperty, AbstractFormatterFactory formatterFactory) { Map context = createContext(FormattedTextFieldBinder.FORMATTER_FACTORY_KEY, formatterFactory); return createBinding(JFormattedTextField.class, formProperty, context); }
public JFormattedTextField createFormattedTextField(AbstractFormatterFactory formatterFactory) { PatchedJFormattedTextField patchedJFormattedTextField = new PatchedJFormattedTextField(formatterFactory); configureTextField(patchedJFormattedTextField); return patchedJFormattedTextField; }
/** * Returns the formatter factory that decides about valid inputs for the search data type. * * @return A valid formatter factory or null. */ AbstractFormatterFactory getFormatterFactory();
/** * Convenience method for creating a formatter factory with a * {@code ScalableNumberFormatter} and a Java-style DecimalFormat. * Doesn't allow null values and doesn't append ".0" to double and float values. */ public static AbstractFormatterFactory createFormatterFactory(double min, double max, double multiplier) { return createFormatterFactory(min, max, multiplier, false, null); }
/** * Convenience method for creating a formatter factory with a * {@code FontFormatter}. * Uses the RGB_INTEGER format and disallows null values. */ public static AbstractFormatterFactory createFormatterFactory() { return createFormatterFactory(false); }
/** * Convenience method for creating a formatter factory with a * {@code ColorFormatter}. * Uses the RGB_INTEGER_SHORT format, allows null values and is adaptive. */ public static AbstractFormatterFactory createFormatterFactory() { return createFormatterFactory(Format.RGB_INTEGER_SHORT, true, true); }
/** * Create a formatted text field using this component factory. * * @param formatterFactory AbstractFormatterFactory used for formatting. * @return The new formatted text field */ public JFormattedTextField createFormattedTextField(AbstractFormatterFactory formatterFactory);