Class Component<T,C>

java.lang.Object
de.julianweinelt.datacat.dbx.api.ui.Component<T,C>
Direct Known Subclasses:
ComponentButton, ComponentCheckbox, ComponentColorPicker, ComponentComboBox, ComponentHorizontalLine, ComponentLabel, ComponentSpinner, ComponentTextField

public abstract class Component<T,C> extends Object
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract JComponent
    Should return the internal Swing object.
    protected JLabel
    Creates the label object for display
    abstract boolean
    Defines if the component should be expanded to the window's width size in the component's parent screen.
    boolean
    Checks if a label has been set for this component
    abstract C
    For setting an initial value that should be displayed before any of the user's input.
    It should always return the instance of the Component.
    label(String label)
    Sets the label to be displayed for the component.
    Set to an empty String to disable the label.
    abstract T
    Should return the value of the Component's Swing Object. e.g., if implementing a text field, it should return the entered value of the text field.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • label

      public C label(String label)
      Sets the label to be displayed for the component.
      Set to an empty String to disable the label.
      Parameters:
      label - A String with the content of the label
      Returns:
      The modified Component object
    • hasLabel

      public boolean hasLabel()
      Checks if a label has been set for this component
      Returns:
      true if the components has a non-empty label, otherwise false
    • createLabel

      @Internal protected JLabel createLabel()
      Creates the label object for display
      Returns:
      A new JLabel containing the text of the component
    • expandHorizontally

      public abstract boolean expandHorizontally()
      Defines if the component should be expanded to the window's width size in the component's parent screen.

      Example: a horizontal line for splitting content
      Returns:
      true if it should be expanded, otherwise false
    • initialValue

      public abstract C initialValue(Object val)
      For setting an initial value that should be displayed before any of the user's input.
      It should always return the instance of the Component.

      Implementation example:
      
       protected JTextField textField;
      
       @Override
       public ComponentTextField initialValue(Object value) {
           if (value instanceof String) {
               textField.setText((String) value);
           }
           return this;
       }
       
      Parameters:
      val - The value to set.
      Returns:
      The Component's instance.
    • value

      public abstract T value()
      Should return the value of the Component's Swing Object. e.g., if implementing a text field, it should return the entered value of the text field.
      Returns:
      The entered value of this component.
    • create

      public abstract JComponent create()
      Should return the internal Swing object.
      Returns:
      An object extending JComponent