public class ValueModelBindingBuilderImpl extends Object implements ValueModelBindingBuilder
It is recommended to create this builder with an optional property name. If such a name is available, it is set a default validation message key for components that are bound with this builder.
ValueModelBindingBuilder.Commit
Constructor and Description |
---|
ValueModelBindingBuilderImpl(ValueModel valueModel)
Creates a ValueModelBindingBuilderImpl for the given ValueModel.
|
ValueModelBindingBuilderImpl(ValueModel valueModel,
String propertyName)
Creates a ValueModelBindingBuilderImpl for the given ValueModel
using the given bean property name.
|
Modifier and Type | Method and Description |
---|---|
<E> SelectionInListBindingBuilder |
asSelectionIn(E[] array)
Creates and returns a SelectionInListBindingBuilder on a SelectionInList
with this builder's ValueModel as selection holder and the given array
as list.
|
<E> SelectionInListBindingBuilder |
asSelectionIn(List<E> list)
Creates and returns a SelectionInListBindingBuilder on a SelectionInList
with this builder's ValueModel as selection holder and the given
list as list elements. |
<E> SelectionInListBindingBuilder |
asSelectionIn(ListModel listModel)
Creates and returns a SelectionInListBindingBuilder on a SelectionInList
with this builder's ValueModel as selection holder and the given
ListModel as list data provider.
|
ValueModelBindingBuilder |
converted(BindingConverter converter)
Wraps this builder's ValueModel with a converting ValueModel
and creates and returns another ValueModelBindingBuilder
with the wrapped ValueModel.
|
ValueModelBindingBuilder |
formatted(Format format)
Wraps this builder's ValueModel with a string converter
and creates and returns another ValueModelBindingBuilder
with the wrapped ValueModel.
|
protected String |
getPropertyName() |
protected ValueModel |
getValueModel() |
protected void |
setValidationMessageKey(JComponent comp)
Sets this builder's property name - if any - as the component's
validation message key.
|
void |
to(AbstractButton toggleButton)
Binds this builder's ValueModel to the given toggle button,
for example a check box.
|
void |
to(AbstractButton toggleButton,
Object choice)
Binds this builder's ValueModel to the given toggle button
(radio button style) that is selected, if and only if the model's value
equals the given
choice . |
void |
to(AbstractButton toggleButton,
Object selectedValue,
Object deselectedValue)
Binds this builder's ValueModel to the given toggle button,
for example a check box.
|
void |
to(JFormattedTextField formattedTextField)
Binds this builder's ValueModel to the given formatted text field.
|
void |
to(JLabel label)
Binds this builder's ValueModel to the given text label.
|
void |
to(JTextArea textArea)
Binds this builder's ValueModel to the given text area and
commits text changes on focus lost.
|
void |
to(JTextArea textArea,
ValueModelBindingBuilder.Commit commitType)
Binds this builder's ValueModel to the given text area using
the specified commit type.
|
void |
to(JTextField textField)
Binds this builder's ValueModel to the given text field and
commits text changes on focus lost.
|
void |
to(JTextField textField,
ValueModelBindingBuilder.Commit commitType)
Binds this builder's ValueModel to the given text field using
the specified commit type.
|
public ValueModelBindingBuilderImpl(ValueModel valueModel)
ValueModelBindingBuilderImpl(ValueModel, String)
where the property name is set.valueModel
- the ValueModel to be managed and boundNullPointerException
- if valueModel
is null
public ValueModelBindingBuilderImpl(ValueModel valueModel, String propertyName)
valueModel
- the ValueModel to be managed and boundpropertyName
- the bean property name that has been used
to create the ValueModel fromNullPointerException
- if valueModel
is null
IllegalArgumentException
- if propertyName
is empty or whitespacepublic ValueModelBindingBuilder converted(BindingConverter converter)
ValueModelBindingBuilder
Example:
binder.bindBeanProperty("price").converted(currencyConverter).to(priceField);
The ConverterFactory
provides a bunch of prepared converters.
When binding non-String values to a text UI component, consider
using a JFormattedTextField
. Formatted text fields
provide a powerful means to convert strings to objects and handle
many cases that arise around invalid input.
converted
in interface ValueModelBindingBuilder
converter
- converts values from the source to the target
and vice versapublic ValueModelBindingBuilder formatted(Format format)
ValueModelBindingBuilder
Example:
binder.bindBeanProperty("count").formatted(percentFormat).to(percentField);
formatted
in interface ValueModelBindingBuilder
format
- implements the String conversion via #format and #parsepublic <E> SelectionInListBindingBuilder asSelectionIn(E[] array)
ValueModelBindingBuilder
Example:
binder.bindBeanProperty("country").asSelectionIn(COUNTRIES).to(countryCombo);
asSelectionIn
in interface ValueModelBindingBuilder
E
- the type of the list elementsarray
- the list data for the SelectionInListpublic <E> SelectionInListBindingBuilder asSelectionIn(List<E> list)
ValueModelBindingBuilder
list
as list elements.
Example:
binder.bindBeanProperty("country").asSelectionIn(COUNTRIES).to(countryCombo);
asSelectionIn
in interface ValueModelBindingBuilder
E
- the type of the list elementslist
- the list data for the SelectionInListpublic <E> SelectionInListBindingBuilder asSelectionIn(ListModel listModel)
ValueModelBindingBuilder
Example:
binder.bindBeanProperty("country").asSelectionIn(COUNTRIES).to(countryCombo);
asSelectionIn
in interface ValueModelBindingBuilder
E
- the type of the list elementslistModel
- the list data for the SelectionInListpublic void to(AbstractButton toggleButton)
ValueModelBindingBuilder
Example:
binder.bindBeanProperty("classical").to(classicalBox);
to
in interface ValueModelBindingBuilder
toggleButton
- the button to be bound to this builder's ValueModelBindings.bind(AbstractButton, com.jgoodies.binding.value.ValueModel)
public void to(AbstractButton toggleButton, Object selectedValue, Object deselectedValue)
ValueModelBindingBuilder
Example:
binder.bindBeanProperty("classical").to(classicalBox, CLASSICAL, PLAIN);
to
in interface ValueModelBindingBuilder
toggleButton
- the button to be bound to this builder's ValueModelselectedValue
- the model's value if the button is selecteddeselectedValue
- the model's value if the button is not selectedBindings.bind(AbstractButton, com.jgoodies.binding.value.ValueModel)
public void to(AbstractButton toggleButton, Object choice)
ValueModelBindingBuilder
choice
.
Example:
binder.bindBeanProperty("alignment").to(alignmentButton, Alignment.LEFT);
to
in interface ValueModelBindingBuilder
toggleButton
- the button to be bound to this builder's ValueModelchoice
- the model value where radioButton
shall be selectedBindings.bind(AbstractButton, com.jgoodies.binding.value.ValueModel, Object)
public void to(JFormattedTextField formattedTextField)
ValueModelBindingBuilder
Example:
binder.bindBeanProperty("releaseDate").to(dateField);
to
in interface ValueModelBindingBuilder
formattedTextField
- the formatted text field to be bound to this builder's ValueModelBindings.bind(JFormattedTextField, com.jgoodies.binding.value.ValueModel)
public void to(JLabel label)
ValueModelBindingBuilder
Example:
binder.binProperty("resultCount").converted(resultFormat).to(tableHeaderLabel);
to
in interface ValueModelBindingBuilder
label
- the label to be bound to this builder's ValueModelBindings.bind(JLabel, com.jgoodies.binding.value.ValueModel)
public void to(JTextArea textArea)
ValueModelBindingBuilder
Example:
binder.bindBeanProperty("comment").to(commentArea);
to
in interface ValueModelBindingBuilder
textArea
- the text area to be bound to this builder's ValueModelBindings.bind(JTextArea, com.jgoodies.binding.value.ValueModel)
public void to(JTextArea textArea, ValueModelBindingBuilder.Commit commitType)
ValueModelBindingBuilder
Examples:
binder.bindBeanProperty("comment").to(commentArea, Commit.ON_KEY_TYPED);
binder.bindBeanProperty("comment").to(commentArea, Commit.ON_FOCUS_LOST);
to
in interface ValueModelBindingBuilder
textArea
- the text area to be bound to this builder's ValueModelcommitType
- the commit type to be used,
either Commit.ON_KEY_TYPED
or Commit.ON_FOCUS_LOST
Bindings.bind(JTextArea, com.jgoodies.binding.value.ValueModel)
public void to(JTextField textField)
ValueModelBindingBuilder
Example:
binder.bindBeanProperty("title").to(titleField);
to
in interface ValueModelBindingBuilder
textField
- the text field to be bound to this builder's ValueModelBindings.bind(JTextField, com.jgoodies.binding.value.ValueModel)
public void to(JTextField textField, ValueModelBindingBuilder.Commit commitType)
ValueModelBindingBuilder
Examples:
binder.bindBeanProperty("title").to(titleField, Commit.ON_KEY_TYPED);
binder.bindBeanProperty("title").to(titleField, Commit.ON_FOCUS_LOST);
to
in interface ValueModelBindingBuilder
textField
- the text field to be bound to this builder's ValueModelcommitType
- the commit type to be used,
either Commit.ON_KEY_TYPED
or Commit.ON_FOCUS_LOST
Bindings.bind(JTextField, com.jgoodies.binding.value.ValueModel)
protected final ValueModel getValueModel()
protected final String getPropertyName()
protected final void setValidationMessageKey(JComponent comp)
comp
- the component where the validation message key shall be setCopyright © 2002-2015 JGoodies Software GmbH. All Rights Reserved.