Class FormComponent

  • All Implemented Interfaces:
    FormSelectable
    Direct Known Subclasses:
    FormContainer, FormNonVisual

    public class FormComponent
    extends FormObject
    implements FormSelectable
    A form component represents a Component in the form model. It has a name, a class name and properties. The name is used by the Java code generator as variable name or by the FormLoader to access the Swing component.

    FormContainer must be used for container components; FormWindow for Window and derived components; FormNonVisual for non-visual JavaBeans (not derived from Component).

    Example:

       FormComponent label = new FormComponent("javax.swing.JLabel");
       label.setProperty("text", "hello");
       label.setProperty("foreground", Color.red);
     
    The same in Swing:
       JLabel label = new JLabel();
       label.setText("hello");
       label.setForeground(Color.red);
     
    • Constructor Detail

      • FormComponent

        public FormComponent​(String className)
        Constructs a form component for the specified class.
    • Method Detail

      • clone

        public Object clone()
        Clones this form component.
        Overrides:
        clone in class Object
      • getName

        public String getName()
        Returns the name of this form component.
      • setName

        public void setName​(String name)
        Sets the name of this form component.
      • getClassName

        public String getClassName()
        Returns the class name of this form component.
      • setClassName

        public void setClassName​(String className)
        Sets the class name of this form component.
        Since:
        7
      • getParent

        public FormContainer getParent()
        Returns the parent of this form component. Or null if the form component has no parent.
      • getModel

        public FormModel getModel()
        Returns the form model of this form component.
      • auxiliary

        public FormObject auxiliary()
        Returns a object that contains auxiliary property. Auxiliary properties are used to store additional information for a form component (e.g. code generation options).
      • hasAuxiliary

        public boolean hasAuxiliary()
        Returns whether this form component has auxiliary properties or not.
      • getAuxiliaryPropertyString

        public String getAuxiliaryPropertyString​(String name,
                                                 String def)
        Convenience method to get an auxiliary String property value. Returns def if the auxiliary property is not a String or does not exist.
      • getAuxiliaryPropertyInt

        public int getAuxiliaryPropertyInt​(String name,
                                           int def)
        Convenience method to get an auxiliary integer property value. Returns def if the auxiliary property is not an integer or does not exist.
      • getAuxiliaryPropertyBoolean

        public boolean getAuxiliaryPropertyBoolean​(String name,
                                                   boolean def)
        Convenience method to get an auxiliary boolean property value. Returns def if the auxiliary property is not a boolean or does not exist.
      • getConstraints

        public FormLayoutConstraints getConstraints()
        Returns the form layout constraints of this form component if the parent container has a form layout manager which uses constraints.
      • getEventCount

        public int getEventCount()
        Returns the number of form events in this form component.
        Since:
        2.0
      • getEvent

        public FormEvent getEvent​(int index)
        Returns the form event at index.
        Since:
        2.0
      • getEvents

        public FormEvent[] getEvents()
        Returns all form events in this form component.
        Since:
        2.0
      • addEvent

        public void addEvent​(FormEvent event)
        Adds a form event to the end of this form component.
        Since:
        2.0
      • addEvent

        public void addEvent​(FormEvent event,
                             int index)
        Adds a form event to this form component at the specified position.
        Parameters:
        event - The form event to be added.
        index - The position in the component's event list at which to insert the event; or -1 to insert at the end
        Since:
        2.0
      • removeEvent

        public void removeEvent​(FormEvent event)
        Removes the specified form event from this form component.
        Since:
        2.0
      • removeEvent

        public void removeEvent​(int index)
        Removes the form event at the specified index from this form component.
        Since:
        2.0
      • toString

        public String toString()
        Returns a string representation of the object.
        Overrides:
        toString in class FormObject