Class AbstractComponentValue<T,C extends JComponent>

java.lang.Object
is.codion.common.value.AbstractValue<T>
is.codion.swing.common.ui.component.value.AbstractComponentValue<T,C>
Type Parameters:
T - the value type
C - the component type
All Implemented Interfaces:
EventObserver<T>, Value<T>, ValueObserver<T>, ComponentValue<T,C>, Consumer<T>, Supplier<T>
Direct Known Subclasses:
AbstractTextComponentValue

public abstract class AbstractComponentValue<T,C extends JComponent> extends AbstractValue<T> implements ComponentValue<T,C>
An abstract base implementation of ComponentValue.
  • Constructor Details

    • AbstractComponentValue

      protected AbstractComponentValue(C component)
      Instantiates a new nullable AbstractComponentValue
      Parameters:
      component - the component
      Throws:
      NullPointerException - in case component is null
    • AbstractComponentValue

      protected AbstractComponentValue(C component, T nullValue)
      Instantiates a new AbstractComponentValue
      Parameters:
      component - the component
      nullValue - the value to use instead of null
      Throws:
      NullPointerException - in case component is null
  • Method Details

    • get

      public final T get()
      Specified by:
      get in interface Supplier<T>
    • component

      public final C component()
      Specified by:
      component in interface ComponentValue<T,C extends JComponent>
      Returns:
      the input component representing the value
    • setValue

      protected final void setValue(T value)
      Description copied from class: AbstractValue
      Sets the actual internal value.
      Specified by:
      setValue in class AbstractValue<T>
      Parameters:
      value - the value
    • getComponentValue

      protected abstract T getComponentValue()
      Returns the value from the underlying component
      Returns:
      the value from the underlying component
      See Also:
    • setComponentValue

      protected abstract void setComponentValue(T value)
      Sets the given value in the underlying component. Note that this method is called on the EDT.
      Parameters:
      value - the value to display in the underlying component
      See Also: