com.jgoodies.binding.binder
Interface ValueModelBindingBuilder

All Known Implementing Classes:
ValueModelBindingBuilderImpl

public interface ValueModelBindingBuilder

Describes a binding builder that holds a ValueModel that can be bound to a variety of components. It also describes methods that operate on the ValueModel (conversion) or create a SelectionInListBuilder that in turn can be bound to combo boxes, lists, and tables. Examples:

 binder.bindBeanProperty("classical").to(classicalBox);
 binder.bindBeanProperty("title")    .to(titleField);
 binder.bind(resultCountValueModel)
       .converted(aTableHeaderFormat).to(tableHeaderLabel);
 binder.bindBeanProperty("country")
       .asSelectionIn(COUNTRY_LIST)  .to(countryCombo);
 

Since:
2.3
Version:
$Revision: 1.12 $
Author:
Karsten Lentzsch

Nested Class Summary
static class ValueModelBindingBuilder.Commit
          Describes the commit types used for text field and text area bindings.
 
Method Summary
<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.
 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.
 

Method Detail

converted

ValueModelBindingBuilder converted(BindingConverter converter)
Wraps this builder's ValueModel with a converting ValueModel and creates and returns another ValueModelBindingBuilder with the wrapped ValueModel.

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.

Parameters:
converter - converts values from the source to the target and vice versa
Returns:
a ValueModelBindingBuilder on a converter that wraps this builder's ValueModel
Throws:
NullPointerException - if converter is null
Since:
2.7

formatted

ValueModelBindingBuilder formatted(Format format)
Wraps this builder's ValueModel with a string converter and creates and returns another ValueModelBindingBuilder with the wrapped ValueModel.

Example:
binder.bindBeanProperty("count").formatted(percentFormat).to(percentField);

Parameters:
format - implements the String conversion via #format and #parse
Returns:
a ValueModelBindingBuilder on a converter that wraps this builder's String ValueModel
Throws:
NullPointerException - if format is null

asSelectionIn

<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.

Example:
binder.bindBeanProperty("country").asSelectionIn(COUNTRIES).to(countryCombo);

Type Parameters:
E - the type of the list elements
Parameters:
array - the list data for the SelectionInList
Returns:
a SelectionInListBindingBuilder on a SelectionInList where this builder's ValueModel is the selection holder
Throws:
NullPointerException - if array is null

asSelectionIn

<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.

Example:
binder.bindBeanProperty("country").asSelectionIn(COUNTRIES).to(countryCombo);

Type Parameters:
E - the type of the list elements
Parameters:
list - the list data for the SelectionInList
Returns:
a SelectionInListBindingBuilder on a SelectionInList where this builder's ValueModel is the selection holder
Throws:
NullPointerException - if list is null

asSelectionIn

<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.

Example:
binder.bindBeanProperty("country").asSelectionIn(COUNTRIES).to(countryCombo);

Type Parameters:
E - the type of the list elements
Parameters:
listModel - the list data for the SelectionInList
Returns:
a SelectionInListBindingBuilder on a SelectionInList where this builder's ValueModel is the selection holder
Throws:
NullPointerException - if listModel is null

to

void to(AbstractButton toggleButton)
Binds this builder's ValueModel to the given toggle button, for example a check box.

Example:
binder.bindBeanProperty("classical").to(classicalBox);

Parameters:
toggleButton - the button to be bound to this builder's ValueModel
Throws:
NullPointerException - if checkBox is null
See Also:
Bindings.bind(AbstractButton, com.jgoodies.binding.value.ValueModel)

to

void to(AbstractButton toggleButton,
        Object selectedValue,
        Object deselectedValue)
Binds this builder's ValueModel to the given toggle button, for example a check box.

Example:
binder.bindBeanProperty("classical").to(classicalBox, CLASSICAL, PLAIN);

Parameters:
toggleButton - the button to be bound to this builder's ValueModel
selectedValue - the model's value if the button is selected
deselectedValue - the model's value if the button is not selected
Throws:
NullPointerException - if checkBox is null
See Also:
Bindings.bind(AbstractButton, com.jgoodies.binding.value.ValueModel)

to

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.

Example:
binder.bindBeanProperty("alignment").to(alignmentButton, Alignment.LEFT);

Parameters:
toggleButton - the button to be bound to this builder's ValueModel
choice - the model value where radioButton shall be selected
Throws:
NullPointerException - if radioButton is null
See Also:
Bindings.bind(AbstractButton, com.jgoodies.binding.value.ValueModel, Object)

to

void to(JFormattedTextField formattedTextField)
Binds this builder's ValueModel to the given formatted text field.

Example:
binder.bindBeanProperty("releaseDate").to(dateField);

Parameters:
formattedTextField - the formatted text field to be bound to this builder's ValueModel
Throws:
NullPointerException - if formattedTextField is null
See Also:
Bindings.bind(JFormattedTextField, com.jgoodies.binding.value.ValueModel)

to

void to(JLabel label)
Binds this builder's ValueModel to the given text label.

Example:
binder.binProperty("resultCount").converted(resultFormat).to(tableHeaderLabel);

Parameters:
label - the label to be bound to this builder's ValueModel
Throws:
NullPointerException - if label is null
See Also:
Bindings.bind(JLabel, com.jgoodies.binding.value.ValueModel)

to

void to(JTextArea textArea)
Binds this builder's ValueModel to the given text area and commits text changes on focus lost.

Example:
binder.bindBeanProperty("comment").to(commentArea);

Parameters:
textArea - the text area to be bound to this builder's ValueModel
Throws:
NullPointerException - if textArea is null
See Also:
Bindings.bind(JTextArea, com.jgoodies.binding.value.ValueModel)

to

void to(JTextArea textArea,
        ValueModelBindingBuilder.Commit commitType)
Binds this builder's ValueModel to the given text area using the specified commit type.

Examples:
binder.bindBeanProperty("comment").to(commentArea, Commit.ON_KEY_TYPED); binder.bindBeanProperty("comment").to(commentArea, Commit.ON_FOCUS_LOST);

Parameters:
textArea - the text area to be bound to this builder's ValueModel
commitType - the commit type to be used, either Commit.ON_KEY_TYPED or Commit.ON_FOCUS_LOST
Throws:
NullPointerException - if textArea or commitType is null
See Also:
Bindings.bind(JTextArea, com.jgoodies.binding.value.ValueModel)

to

void to(JTextField textField)
Binds this builder's ValueModel to the given text field and commits text changes on focus lost.

Example:
binder.bindBeanProperty("title").to(titleField);

Parameters:
textField - the text field to be bound to this builder's ValueModel
Throws:
NullPointerException - if textField is null
See Also:
Bindings.bind(JTextField, com.jgoodies.binding.value.ValueModel)

to

void to(JTextField textField,
        ValueModelBindingBuilder.Commit commitType)
Binds this builder's ValueModel to the given text field using the specified commit type.

Examples:
binder.bindBeanProperty("title").to(titleField, Commit.ON_KEY_TYPED); binder.bindBeanProperty("title").to(titleField, Commit.ON_FOCUS_LOST);

Parameters:
textField - the text field to be bound to this builder's ValueModel
commitType - the commit type to be used, either Commit.ON_KEY_TYPED or Commit.ON_FOCUS_LOST
Throws:
NullPointerException - if textField or commitType is null
See Also:
Bindings.bind(JTextField, com.jgoodies.binding.value.ValueModel)


Copyright © 2002-2013 JGoodies Software GmbH. All Rights Reserved.