JGComponentFactory
from the
JGoodies Component library.@Deprecated public class BasicComponentFactory extends Object
com.jgoodies.binding.adapter
.
2) this BasicComponentFactory creates Swing components that are then
tied to ValueModels using the the different #bind
methods
in the Bindings class.If you have an existing factory that vends Swing components, you can use Bindings to bind them to ValueModels. If you don't have such a factory, you can use this BasicComponentFactory to create and bind Swing components.
This class is intended to be used or extended by custom ComponentFactory classes. Such a factory can create a broader variety of component types, may use different default configurations, and can use your favorite Formatters, FormatterFactories, etc.
ValueModel
,
Bindings
Modifier | Constructor and Description |
---|---|
protected |
BasicComponentFactory()
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
static JCheckBox |
createCheckBox(ValueModel valueModel,
String markedText)
Deprecated.
Creates and returns a check box with the specified text label
that is bound to the given ValueModel.
|
static JColorChooser |
createColorChooser(ValueModel valueModel)
Deprecated.
Creates and returns a JColorChooser that has the color selection bound
to the given ValueModel.
|
static JColorChooser |
createColorChooser(ValueModel valueModel,
Color defaultColor)
Deprecated.
Creates and returns a JColorChooser that has the color selection bound
to the given ValueModel.
|
static <E> JComboBox |
createComboBox(SelectionInList<E> selectionInList)
Deprecated.
Creates and returns a non-editable JComboBox that is bound
to the given SelectionInList.
|
static <E> JComboBox |
createComboBox(SelectionInList<E> selectionInList,
ListCellRenderer cellRenderer)
Deprecated.
Creates and returns a non-editable JComboBox that is bound
to the given SelectionInList using the given cell renderer.
|
static JFormattedTextField |
createDateField(ValueModel valueModel)
Deprecated.
Creates and returns a formatted text field that is bound
to the Date value of the given ValueModel.
|
static JFormattedTextField |
createFormattedTextField(ValueModel valueModel,
Format format)
Deprecated.
Creates and returns a formatted text field that binds its value
to the given model and converts Strings to values using
the given Format.
|
static JFormattedTextField |
createFormattedTextField(ValueModel valueModel,
JFormattedTextField.AbstractFormatter formatter)
Deprecated.
Creates and returns a formatted text field that binds its value
to the given model and converts Strings to values using
the given Formatter.
|
static JFormattedTextField |
createFormattedTextField(ValueModel valueModel,
JFormattedTextField.AbstractFormatterFactory formatterFactory)
Deprecated.
Creates and returns a formatted text field that binds its value
to the given model and converts Strings to values using
Formatters provided by the given AbstractFormatterFactory.
|
static JFormattedTextField |
createFormattedTextField(ValueModel valueModel,
String mask)
Deprecated.
Creates and returns a formatted text field that binds its value
to the given model and converts Strings to values using
a MaskFormatter that is based on the given mask.
|
static JFormattedTextField |
createIntegerField(ValueModel valueModel)
Deprecated.
Creates and returns a formatted text field that is bound
to the Integer value of the given ValueModel.
|
static JFormattedTextField |
createIntegerField(ValueModel valueModel,
int emptyNumber)
Deprecated.
Creates and returns a formatted text field that is bound
to the Integer value of the given ValueModel.
|
static JFormattedTextField |
createIntegerField(ValueModel valueModel,
NumberFormat numberFormat)
Deprecated.
Creates and returns a formatted text field that is bound
to the Integer value of the given ValueModel.
|
static JFormattedTextField |
createIntegerField(ValueModel valueModel,
NumberFormat numberFormat,
int emptyNumber)
Deprecated.
Creates and returns a formatted text field that is bound
to the Integer value of the given ValueModel.
|
static JFormattedTextField |
createIntegerField(ValueModel valueModel,
NumberFormat numberFormat,
Integer emptyNumber)
Deprecated.
Creates and returns a formatted text field that is bound
to the Integer value of the given ValueModel.
|
static JLabel |
createLabel(ValueModel valueModel)
Deprecated.
Creates and returns a text label that is bound to the given ValueModel.
|
static JLabel |
createLabel(ValueModel valueModel,
Format format)
Deprecated.
Creates and returns a text label that is bound to the
given ValueModel that is wrapped by a
StringConverter . |
static <E> JList |
createList(SelectionInList<E> selectionInList)
Deprecated.
Creates and returns a JList for the given SelectionInList.
|
static <E> JList |
createList(SelectionInList<E> selectionInList,
ListCellRenderer cellRenderer)
Deprecated.
Creates and returns a JList for the given SelectionInList using
the specified optional ListCellRenderer to render cells.
|
static JFormattedTextField |
createLongField(ValueModel valueModel)
Deprecated.
Creates and returns a formatted text field that is bound
to the Long value of the given ValueModel.
|
static JFormattedTextField |
createLongField(ValueModel valueModel,
long emptyNumber)
Deprecated.
Creates and returns a formatted text field that is bound to the
Long value of the given ValueModel.
|
static JFormattedTextField |
createLongField(ValueModel valueModel,
NumberFormat numberFormat)
Deprecated.
Creates and returns a formatted text field that is bound to the
Long value of the given ValueModel.
|
static JFormattedTextField |
createLongField(ValueModel valueModel,
NumberFormat numberFormat,
long emptyNumber)
Deprecated.
Creates and returns a formatted text field that is bound to the
Long value of the given ValueModel.
|
static JFormattedTextField |
createLongField(ValueModel valueModel,
NumberFormat numberFormat,
Long emptyNumber)
Deprecated.
Creates and returns a formatted text field that is bound to the
Long value of the given ValueModel.
|
static JPasswordField |
createPasswordField(ValueModel valueModel)
Deprecated.
Creates and returns a JPasswordField with the content bound
to the given ValueModel.
|
static JPasswordField |
createPasswordField(ValueModel valueModel,
boolean commitOnFocusLost)
Deprecated.
Creates and returns a JPasswordField with the content bound
to the given ValueModel.
|
static JRadioButton |
createRadioButton(ValueModel model,
Object choice,
String markedText)
Deprecated.
Creates and returns a radio button with the specified text label
that is bound to the given ValueModel.
|
static JTable |
createTable(SelectionInList selectionInList,
AbstractTableAdapter<?> tableAdapter)
Deprecated.
Creates and returns a table that turns the SelectionInList's row data
into a TableModel using the given adapter.
|
static JTextArea |
createTextArea(ValueModel valueModel)
Deprecated.
Creates and returns a text area with the content bound to the given
ValueModel.
|
static JTextArea |
createTextArea(ValueModel valueModel,
boolean commitOnFocusLost)
Deprecated.
Creates and returns a text area with the content bound to the given
ValueModel.
|
static JTextField |
createTextField(ValueModel valueModel)
Deprecated.
Creates and returns a text field with the content bound
to the given ValueModel.
|
static JTextField |
createTextField(ValueModel valueModel,
boolean commitOnFocusLost)
Deprecated.
Creates and returns a text field with the content bound
to the given ValueModel.
|
public static JCheckBox createCheckBox(ValueModel valueModel, String markedText)
Boolean.TRUE
.
The created check box' content area is not filled, and
a mnemonic is set, if the text contains a mnemonic marker
('&'). See MnemonicUtils
for detailed information
about mnemonic markers and how to quote the marker character.The model is converted to the required ToggleButtonModel using a ToggleButtonAdapter.
valueModel
- the model that provides a Boolean valuemarkedText
- the check boxes' text label
- may contain a mnemonic markerNullPointerException
- if the valueModel is null
public static JColorChooser createColorChooser(ValueModel valueModel)
null
.
It is strongly recommended (though not required)
that the underlying ValueModel provides only non-null values.
This is so because the ColorSelectionModel behavior is undefined
for null
values and it may have unpredictable results.
To avoid these problems, you may create the ColorChooser with
a default color using createColorChooser(ValueModel, Color)
.
valueModel
- a Color-typed ValueModelNullPointerException
- if the valueModel is null
,
or if its initial value is null
createColorChooser(ValueModel, Color)
public static JColorChooser createColorChooser(ValueModel valueModel, Color defaultColor)
null
, the given default color is used instead.
This avoids problems with the ColorSelectionModel that may have
unpredictable result for null
values.valueModel
- a Color-typed ValueModeldefaultColor
- the color used if the valueModel returns nullNullPointerException
- if the valueModel or the default color
is null
,public static <E> JComboBox createComboBox(SelectionInList<E> selectionInList)
If the selectionInList's selection holder is a ComponentValueModel
it is synchronized with the visible and enabled state of the returned
combo box.
There are a couple of other possibilities to bind a JComboBox.
See the constructors and the class comment of the
ComboBoxAdapter
.
E
- the type of the combo box items and the selectionselectionInList
- provides the list and selectionNullPointerException
- if the selectionInList
is null
ComboBoxAdapter
public static <E> JComboBox createComboBox(SelectionInList<E> selectionInList, ListCellRenderer cellRenderer)
If the selectionInList's selection holder is a ComponentValueModel
it is synchronized with the visible and enabled state of the returned
combo box.
There are a couple of other possibilities to bind a JComboBox.
See the constructors and the class comment of the
ComboBoxAdapter
.
E
- the type of the combo box items and the selectionselectionInList
- provides the list and selectioncellRenderer
- an optional ListCellRenderer,
can be null
null
NullPointerException
- if the selectionInList
is null
ComboBoxAdapter
public static JFormattedTextField createDateField(ValueModel valueModel)
SHORT
DateFormat with strict checking is used to edit
(parse) a date; the DateFormatter's default DateFormat is used to
display (format) a date. In both cases null
Dates are
mapped to the empty String.valueModel
- the model that holds the value to be editedNullPointerException
- if the valueModel is null
public static JFormattedTextField createFormattedTextField(ValueModel valueModel, Format format)
valueModel
- the model that provides the valueformat
- the Format
used to convert values
into a text representation and vice versa via #format
and #parse
NullPointerException
- if the valueModel is null
public static JFormattedTextField createFormattedTextField(ValueModel valueModel, JFormattedTextField.AbstractFormatter formatter)
valueModel
- the model that provides the valueformatter
- the Formatter used to convert values to
a text representation and vice versa via #valueToString
and #stringToValue
NullPointerException
- if the valueModel is null
public static JFormattedTextField createFormattedTextField(ValueModel valueModel, JFormattedTextField.AbstractFormatterFactory formatterFactory)
valueModel
- the model that provides the valueformatterFactory
- provides formatters for different field states
that in turn are used to convert values to a text representation and
vice versa via #valueToString
and #stringToValue
NullPointerException
- if the valueModel is null
public static JFormattedTextField createFormattedTextField(ValueModel valueModel, String mask)
valueModel
- the model that provides the valuemask
- the mask pattern used to create an instance of
MaskFormatter
that in turn converts values to Strings
and vice versaNullPointerException
- if the valueModel is null
IllegalArgumentException
- if the mask is invalidpublic static JFormattedTextField createIntegerField(ValueModel valueModel)
null
and vice versa.
The Format used to convert numbers to strings and vice versa
is NumberFormat.getIntegerInstance()
.
valueModel
- the model that holds the value to be editedNullPointerException
- if the valueModel is null
public static JFormattedTextField createIntegerField(ValueModel valueModel, int emptyNumber)
The Format used to convert numbers to strings and vice versa
is NumberFormat.getIntegerInstance()
.
valueModel
- the model that holds the value to be editedemptyNumber
- an Integer that represents the empty stringNullPointerException
- if the valueModel is null
public static JFormattedTextField createIntegerField(ValueModel valueModel, NumberFormat numberFormat)
null
and vice versa.valueModel
- the model that holds the value to be editednumberFormat
- used to convert numbers to strings and vice versaNullPointerException
- if the valueModel is null
public static JFormattedTextField createIntegerField(ValueModel valueModel, NumberFormat numberFormat, int emptyNumber)
valueModel
- the model that holds the value to be editednumberFormat
- used to convert numbers to strings and vice versaemptyNumber
- an Integer that represents the empty stringNullPointerException
- if the valueModel is null
public static JFormattedTextField createIntegerField(ValueModel valueModel, NumberFormat numberFormat, Integer emptyNumber)
valueModel
- the model that holds the value to be editednumberFormat
- used to convert numbers to strings and vice versaemptyNumber
- an Integer that represents the empty stringNullPointerException
- if the valueModel is null
public static JFormattedTextField createLongField(ValueModel valueModel)
null
and vice versa.
The Format used to convert numbers to strings and vice versa is
NumberFormat.getIntegerInstance()
.
valueModel
- the model that holds the value to be editedNullPointerException
- if the model is null
public static JFormattedTextField createLongField(ValueModel valueModel, long emptyNumber)
The Format used to convert numbers to strings and vice versa is
NumberFormat.getIntegerInstance()
.
valueModel
- the model that holds the value to be editedemptyNumber
- a Long that represents the empty stringNullPointerException
- if the model is null
public static JFormattedTextField createLongField(ValueModel valueModel, NumberFormat numberFormat)
null
and vice versa.valueModel
- the model that holds the value to be editednumberFormat
- used to convert numbers to strings and vice versaNullPointerException
- if the model is null
public static JFormattedTextField createLongField(ValueModel valueModel, NumberFormat numberFormat, long emptyNumber)
valueModel
- the model that holds the value to be editednumberFormat
- used to convert numbers to strings and vice versaemptyNumber
- a Long that represents the empty stringNullPointerException
- if the model is null
public static JFormattedTextField createLongField(ValueModel valueModel, NumberFormat numberFormat, Long emptyNumber)
valueModel
- the model that holds the value to be editednumberFormat
- used to convert numbers to strings and vice versaemptyNumber
- a Long that represents the empty stringNullPointerException
- if the model is null
public static JLabel createLabel(ValueModel valueModel)
valueModel
- the model that provides the valueNullPointerException
- if the valueModel is null
public static JLabel createLabel(ValueModel valueModel, Format format)
StringConverter
.
The conversion to Strings uses the specified Format.valueModel
- the model that provides the valueformat
- the format used to create the StringConverterNullPointerException
- if the valueModel is null
ConverterFactory
public static <E> JList createList(SelectionInList<E> selectionInList)
If the selectionInList's selection holder is a ComponentValueModel
it is synchronized with the visible and enabled state of the returned
list.
E
- the type of the list items and the selectionselectionInList
- provides the list and selectionNullPointerException
- if selectionInList is null
public static <E> JList createList(SelectionInList<E> selectionInList, ListCellRenderer cellRenderer)
If the selectionInList's selection holder is a ComponentValueModel
it is synchronized with the visible and enabled state of the returned
list.
E
- the type of the list items and the selectionselectionInList
- provides the list and selectioncellRenderer
- an optional ListCellRenderer,
can be null
NullPointerException
- if selectionInList is null
public static JPasswordField createPasswordField(ValueModel valueModel)
Security Note: The binding created by this method
uses Strings as values of the given ValueModel. The String-typed
passwords could potentially be observed in a security fraud.
For stronger security it is recommended to request a character array
from the JPasswordField and clear the array after use by setting
each character to zero. Method JPasswordField.getPassword()
return's the field's password as a character array.
valueModel
- the model that provides the valueNullPointerException
- if the valueModel is null
createPasswordField(ValueModel, boolean)
,
JPasswordField.getPassword()
public static JPasswordField createPasswordField(ValueModel valueModel, boolean commitOnFocusLost)
Security Note: The binding created by this method
uses Strings as values of the given ValueModel. The String-typed
passwords could potentially be observed in a security fraud.
For stronger security it is recommended to request a character array
from the JPasswordField and clear the array after use by setting
each character to zero. Method JPasswordField.getPassword()
return's the field's password as a character array.
valueModel
- the model that provides the valuecommitOnFocusLost
- true to commit text changes on focus lost,
false to commit text changes on every character typedNullPointerException
- if the valueModel is null
createPasswordField(ValueModel)
,
JPasswordField.getPassword()
public static JRadioButton createRadioButton(ValueModel model, Object choice, String markedText)
MnemonicUtils
for detailed information
about mnemonic markers and how to quote the marker character.The model is converted to the required ToggleButton using a RadioButtonAdapter.
model
- the model that provides the current choicechoice
- this button's valuemarkedText
- the radio buttons' text label
- may contain a mnemonic markerNullPointerException
- if the valueModel is null
public static JTable createTable(SelectionInList selectionInList, AbstractTableAdapter<?> tableAdapter)
selectionInList
- provides the row data and selection indextableAdapter
- converts row data to TableModelNullPointerException
- if selectionInList
or tableAdapter
is null
public static JTextArea createTextArea(ValueModel valueModel)
valueModel
- the model that provides the valueNullPointerException
- if the valueModel is null
createTextArea(ValueModel, boolean)
public static JTextArea createTextArea(ValueModel valueModel, boolean commitOnFocusLost)
valueModel
- the model that provides the text valuecommitOnFocusLost
- true to commit text changes on focus lost,
false to commit text changes on every character typedNullPointerException
- if the valueModel is null
createTextArea(ValueModel)
public static JTextField createTextField(ValueModel valueModel)
valueModel
- the model that provides the valueNullPointerException
- if the valueModel is null
createTextField(ValueModel, boolean)
public static JTextField createTextField(ValueModel valueModel, boolean commitOnFocusLost)
valueModel
- the model that provides the text valuecommitOnFocusLost
- true to commit text changes on focus lost,
false to commit text changes on every character typedNullPointerException
- if the valueModel is null
createTextField(ValueModel)
Copyright © 2002-2015 JGoodies Software GmbH. All Rights Reserved.