Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.jgoodies.binding.value
Interface ComponentValueModel

All Superinterfaces:
  ComponentModel, com.jgoodies.common.bean.ObservableBean, com.jgoodies.common.bean.ObservableBean2, ValueModel

All Known Implementing Classes:
  AbstractConverter, AbstractWrappedValueModel, ConverterFactory.BooleanNegator, ConverterFactory.BooleanToStringConverter, ConverterFactory.DoubleConverter, ConverterFactory.DoubleToIntegerConverter, ConverterFactory.FloatConverter, ConverterFactory.FloatToIntegerConverter, ConverterFactory.IntegerConverter, ConverterFactory.LongConverter, ConverterFactory.LongToIntegerConverter, ConverterFactory.StringConverter, DefaultComponentValueModel

    public interface ComponentValueModel

extends ValueModel, ComponentModel

Adds bound properties for the frequently used JComponent state enabled,visible and JTextComponent state editable to the ValueModel interface. ComponentValueModels can be used to set these properties at the presentation model layer; any ComponentValueModel property change will be reflected by components bound to that ComponentValueModel.

The ComponentValueModel is similar to the Swing Action class. If you disable an Action, all buttons and menu items bound to that Action will be disabled. If you disable a ComponentValueModel, all components bound to that ComponentValueModel will be disabled. If you set the ComponentValueModel to invisible, the component bound to it will become invisible. If you set a ComponentValueModel to non-editable, the JTextComponents bound to it will become non-editable.

Since version 1.1, PresentationModels can vend ComponentValueModels using `#getComponentModel(String)` and `#getBufferedComponentModel(String)`. Multiple calls to these factory methods return the same ComponentValueModel.

The BasicComponentFactory and the Bindings class check if the ValueModel provided to create/bind a Swing component is a ComponentValueModel. If so, the ComponentValueModel properties will be synchronized with the associated Swing component properties.

It is recommended to use ComponentValueModels only for those models that are bound to view components that require GUI state changes.

Example Code:

     final class AlbumView {

      ...

         private void initComponents() {
             // No state modifications required for the name field.
             nameField = BasicComponentFactory.createTextField(
                 presentationModel.getModel(Album.PROPERTYNAME_NAME));
             ...
             // Enablement shall change for the composer field
             composerField = BasicComponentFactory.createTextField(
                 presentationModel.getComponentModel(Album.PROPERTYNAME_COMPOSER));
             ...
         }

      ...

     }

     public final class AlbumPresentationModel extends PresentationModel {

      ...

         private void updateComposerEnablement(boolean enabled) {
             getComponentModel(Album.PROPERTYNAME_COMPOSER).setEnabled(enabled);
         }

      ...

     }

As of the Binding version 2.0 the ComponentValueModel feature is implemented for text components, radio buttons, check boxes, combo boxes, and lists. JColorChoosers bound using the Bindings class will ignore ComponentValueModel state.

Since:
  2.4
Version:
  $Revision: 1.15 $
Author:
  Karsten Lentzsch
See Also:
  `PresentationModel.getComponentModel(String)`, `PresentationModel.getBufferedComponentModel(String)`, `BasicComponentFactory`, `Bindings`

Field Summary
`static String` | `PROPERTYNAME_EDITABLE` Deprecated. Replaced by `ComponentModel.PROPERTY_EDITABLE`.
`static String` | `PROPERTYNAME_ENABLED` Deprecated. Replaced by `ComponentModel.PROPERTY_ENABLED`.
`static String` | `PROPERTYNAME_VISIBLE` Deprecated. Replaced by `ComponentModel.PROPERTY_VISIBLE`.

Fields inherited from interface com.jgoodies.binding.value.ComponentModel
`PROPERTY_EDITABLE, PROPERTY_ENABLED, PROPERTY_VISIBLE`

Method Summary

Methods inherited from interface com.jgoodies.binding.value.ValueModel
`addValueChangeListener, getValue, removeValueChangeListener, setValue`

Methods inherited from interface com.jgoodies.binding.value.ComponentModel
`isEditable, isEnabled, isVisible, setEditable, setEnabled, setVisible`

Methods inherited from interface com.jgoodies.common.bean.ObservableBean2
`addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener`

Methods inherited from interface com.jgoodies.common.bean.ObservableBean
`addPropertyChangeListener, removePropertyChangeListener`

Field Detail

### PROPERTYNAME_ENABLED

    @Deprecated
    static final String PROPERTYNAME_ENABLED

  Deprecated. Replaced by `ComponentModel.PROPERTY_ENABLED`.
  The name of the property used to synchronize this model with the enabled property of JComponents.

  See Also:
    Constant Field Values

### PROPERTYNAME_VISIBLE

    @Deprecated
    static final String PROPERTYNAME_VISIBLE

  Deprecated. Replaced by `ComponentModel.PROPERTY_VISIBLE`.
  The name of the property used to synchronize this model with the visible property of JComponents.

  See Also:
    Constant Field Values

### PROPERTYNAME_EDITABLE

    @Deprecated
    static final String PROPERTYNAME_EDITABLE

  Deprecated. Replaced by `ComponentModel.PROPERTY_EDITABLE`.
  The name of the property used to synchronize this model with the editable property of JTextComponents.

  See Also:
    Constant Field Values

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2002-2011 JGoodies Karsten Lentzsch. All Rights Reserved.