java.lang.Object
org.proto4j.swing.FieldReference<V>
- Type Parameters:
 V- the component's type (field's value type)
public final class FieldReference<V>
extends java.lang.Object
When a GUI is generated, 
FieldReferences are created automatically.
 They are storing different informational data about the linked field.
 This class is thread-safe: multiple threads can share a single FieldReference object without the need for external synchronization.
- 
Field Summary
Fields Modifier and Type Field Description static java.lang.StringTHISWhen fields want to reference the root component, they should use this variable to point to it. - 
Constructor Summary
Constructors Constructor Description FieldReference(int id)Creates a newFieldReferencewith the given id; - 
Method Summary
Modifier and Type Method Description voidaddEventListener(java.util.EventListener listener)Appends the givenEventListenerat the end of the stored listeners.Vget()Tries to return the stored field value and cast it to the referenced type<V>.ComponentDescgetDescription()java.util.EventListener[]getEventListeners()intgetId()java.lang.Class<?>getType()Returns the stored component type.voidset(V value)Applies a new value to the linked field.voidsetComponentDesc(ComponentDesc desc)Applies a newComponentDescto this reference if there is none defined.voidsetParent(java.lang.Object parent)Sets the referenced GUI instance. 
- 
Field Details
- 
THIS
public static final java.lang.String THISWhen fields want to reference the root component, they should use this variable to point to it.Note: The
get()method will return the parent/ root component on field references with$thisas its name.- Since:
 - 1.1.0
 - See Also:
 - Constant Field Values
 
 
 - 
 - 
Constructor Details
- 
FieldReference
public FieldReference(int id)Creates a newFieldReferencewith the given id;- Parameters:
 id- the field's component number
 
 - 
 - 
Method Details
- 
get
Tries to return the stored field value and cast it to the referenced type<V>.- Returns:
 - the field's value
 - Throws:
 java.lang.NullPointerException- if the stored instance isnulljava.lang.ClassCastException- if the stored value can not be casted to<V>
 - 
set
Applies a new value to the linked field.- Parameters:
 value- the new value- Throws:
 java.lang.NullPointerException- if the value isnull
 - 
getId
public int getId()- Returns:
 - the field's component number
 
 - 
getDescription
- Returns:
 - the description for the linked component
 
 - 
getType
public java.lang.Class<?> getType()Returns the stored component type. This value may be null if the linked field has no value applied to it yet.- Returns:
 - the stored component type
 
 - 
addEventListener
public void addEventListener(java.util.EventListener listener)Appends the givenEventListenerat the end of the stored listeners.- Parameters:
 listener- theEventListenerto add
 - 
getEventListeners
public java.util.EventListener[] getEventListeners()- Returns:
 - all stored 
EventListenerobjects 
 - 
setComponentDesc
Applies a newComponentDescto this reference if there is none defined.- Parameters:
 desc- the newComponentDescobject
 - 
setParent
public void setParent(java.lang.Object parent)Sets the referenced GUI instance.- Parameters:
 parent- the GUI's instance
 
 -