Class ButtonProperty

java.lang.Object
ca.corbett.extras.properties.AbstractProperty
ca.corbett.extras.properties.ButtonProperty

public class ButtonProperty extends AbstractProperty
Wraps a ButtonField, and allows you to add buttons to a FormPanel dynamically. Note that this property stores no data! As such, the loadFromFormField method here does nothing. This property exists solely to allow buttons to be added to a FormPanel via the property mechanism. You can add a FormFieldGenerationListener to this property to be notified when the empty ButtonField is generated, and then add buttons to it as needed.
Since:
swing-extras 2.6
Author:
scorbo2
  • Constructor Details

    • ButtonProperty

      public ButtonProperty(String fullyQualifiedName)
    • ButtonProperty

      public ButtonProperty(String fullyQualifiedName, String propertyLabel)
  • Method Details

    • isAllowsUserInput

      public boolean isAllowsUserInput()
      Most properties generate FormField instances that allow user input, but we do not:
      Overrides:
      isAllowsUserInput in class AbstractProperty
      Returns:
      false, to indicate that we are effectively read-only.
    • getAlignment

      public int getAlignment()
      One of the FlowLayout alignment constants: LEFT, CENTER, RIGHT, LEADING, or TRAILING.
    • setAlignment

      public ButtonProperty setAlignment(int alignment)
      One of the FlowLayout alignment constants: LEFT, CENTER, RIGHT, LEADING, or TRAILING.
    • getHgap

      public int getHgap()
      The horizontal gap between buttons.
    • setHgap

      public ButtonProperty setHgap(int hgap)
      The horizontal gap between buttons.
    • getVgap

      public int getVgap()
      The vertical gap between buttons.
    • setVgap

      public ButtonProperty setVgap(int vgap)
      The vertical gap between buttons.
    • getButtonPreferredSize

      public Dimension getButtonPreferredSize()
      The preferred size for buttons in this ButtonField. If null, buttons will use their own preferred size.
    • setButtonPreferredSize

      public void setButtonPreferredSize(Dimension buttonPreferredSize)
      Sets the preferred size for buttons in this ButtonField. If null, buttons will use their own preferred size.
    • saveToProps

      public void saveToProps(Properties props)
      Description copied from class: AbstractProperty
      Saves the current value(s) of this property to the given Properties instance.
      Specified by:
      saveToProps in class AbstractProperty
      Parameters:
      props - Any Properties instance which will receive the value(s) of this property.
    • loadFromProps

      public void loadFromProps(Properties props)
      Description copied from class: AbstractProperty
      Loads the value(s) for this property from the given Properties instance, overwriting any current value. The current value of this property will be used as a default value in the event that this property does not exist in the given Properties instance.
      Specified by:
      loadFromProps in class AbstractProperty
      Parameters:
      props - Any Properties instance which contains value(s) for this property.
    • generateFormFieldImpl

      protected FormField generateFormFieldImpl()
      Creates and returns an empty ButtonField. Add a FormFieldGenerationListener to be notified when the field is created, so you can add buttons to it as needed.
      Specified by:
      generateFormFieldImpl in class AbstractProperty
      Returns:
      A FormField associated with this property.
    • loadFromFormField

      public void loadFromFormField(FormField field)
      Description copied from class: AbstractProperty
      Populates this Property's value(s) from the given form field, assuming the field is of the correct type.
      Specified by:
      loadFromFormField in class AbstractProperty
      Parameters:
      field - The FormField containing a value for this property.