Package com.jformdesigner.model
Class FormComponent
- java.lang.Object
-
- com.jformdesigner.model.FormObject
-
- com.jformdesigner.model.FormComponent
-
- All Implemented Interfaces:
FormSelectable
- Direct Known Subclasses:
FormContainer,FormNonVisual
public class FormComponent extends FormObject implements FormSelectable
A form component represents aComponentin 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.FormContainermust be used for container components;FormWindowforWindowand derived components;FormNonVisualfor non-visual JavaBeans (not derived fromComponent).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);
-
-
Field Summary
Fields Modifier and Type Field Description static StringFIELD_CLASS_NAMEstatic StringFIELD_NAME-
Fields inherited from class com.jformdesigner.model.FormObject
NULL_VALUE
-
-
Constructor Summary
Constructors Constructor Description FormComponent(String className)Constructs a form component for the specified class.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaccept(FormComponentVisitor visitor)Accepts the given visitor.voidaddEvent(FormEvent event)Adds a form event to the end of this form component.voidaddEvent(FormEvent event, int index)Adds a form event to this form component at the specified position.FormObjectauxiliary()Returns a object that contains auxiliary property.Objectclone()Clones this form component.booleangetAuxiliaryPropertyBoolean(String name, boolean def)Convenience method to get an auxiliary boolean property value.intgetAuxiliaryPropertyInt(String name, int def)Convenience method to get an auxiliary integer property value.StringgetAuxiliaryPropertyString(String name, String def)Convenience method to get an auxiliary String property value.StringgetClassName()Returns the class name of this form component.FormLayoutConstraintsgetConstraints()Returns the form layout constraints of this form component if the parent container has a form layout manager which uses constraints.FormEventgetEvent(int index)Returns the form event atindex.intgetEventCount()Returns the number of form events in this form component.FormEvent[]getEvents()Returns all form events in this form component.FormModelgetModel()Returns the form model of this form component.StringgetName()Returns the name of this form component.FormContainergetParent()Returns the parent of this form component.booleanhasAuxiliary()Returns whether this form component has auxiliary properties or not.voidremoveEvent(int index)Removes the form event at the specified index from this form component.voidremoveEvent(FormEvent event)Removes the specified form event from this form component.voidsetClassName(String className)Sets the class name of this form component.voidsetName(String name)Sets the name of this form component.StringtoString()Returns a string representation of the object.-
Methods inherited from class com.jformdesigner.model.FormObject
equals, getClientProperty, getProperties, getProperty, getProperty, getPropertyBoolean, getPropertyBoolean, getPropertyCount, getPropertyDouble, getPropertyDouble, getPropertyInt, getPropertyInt, getPropertyNames, getPropertyString, getPropertyString, getReferenceCount, hashCode, properties, propertyNames, putClientProperty, setProperty, setProperty, setProperty, setPropertyBoolean, setPropertyBoolean, setPropertyDouble, setPropertyDouble, setPropertyInt, setPropertyInt, setPropertyString
-
-
-
-
Field Detail
-
FIELD_NAME
public static final String FIELD_NAME
- See Also:
- Constant Field Values
-
FIELD_CLASS_NAME
public static final String FIELD_CLASS_NAME
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
FormComponent
public FormComponent(String className)
Constructs a form component for the specified class.
-
-
Method Detail
-
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. Ornullif 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. Returnsdefif 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. Returnsdefif 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. Returnsdefif 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.
-
accept
public boolean accept(FormComponentVisitor visitor)
Accepts the given visitor. The visitor'sFormComponentVisitor.visit(com.jformdesigner.model.FormComponent)is called with this form component.- Parameters:
visitor- The visitor.- Returns:
- The result of
FormComponentVisitor.visit(com.jformdesigner.model.FormComponent). - Since:
- 3.0
-
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 atindex.- 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:
toStringin classFormObject
-
-