Package org.faceless.pdf2
Class FormElement
- java.lang.Object
-
- org.faceless.pdf2.FormElement
-
- All Implemented Interfaces:
Cloneable
- Direct Known Subclasses:
FormBarCode,FormButton,FormCheckbox,FormChoice,FormRadioButton,FormSignature,FormText
public abstract class FormElement extends Object
TheFormElementclass is the baseclass for all elements which may be added to aForm.- Since:
- 1.1.13
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddPropertyChangeListener(PropertyChangeListener l)Add a PropertyChangeListener to this FormElement.protected Objectclone()FormElementduplicate()Create an exact copy of this FormElement, but with no annotationsvoidflatten()Flatten the form field so that the contents of it's annotation are permanently stamped on the page.PDFActiongetAction(Event event)Get the action that's performed when the specified event takes place on this field.WidgetAnnotationgetAnnotation(int annot)Return the specified annotation.List<WidgetAnnotation>getAnnotations()Return a list of all the annotations associated with this form element.StringgetDescription()Return the text description of this field if specified, ornullif no description is supplied.FormgetForm()Return the form this form element belongs toabstract StringgetValue()Return the value for this element.booleanisReadOnly()Get whether the field is read-only or not.booleanisRequired()Get whether the field is required before the form is submitted.booleanisSubmitted()Get whether the field is submitted or not.voidrebuild()Cause the annotation list to be rebuilt.voidremovePropertyChangeListener(PropertyChangeListener l)Remove a previously added PropertyChangeListener form this FormElement.voidsetAction(Event event, PDFAction action)Set the action to perform when the specified event takes place on this field.voidsetDescription(String s)Set the text description of this field.voidsetReadOnly(boolean readonly)Set whether the field is read-only or not.voidsetRequired(boolean required)Set whether the field is required before the form is submitted.voidsetSubmitted(boolean submit)Set whether the field is submitted or not.StringtoString()
-
-
-
Method Detail
-
duplicate
public FormElement duplicate()
Create an exact copy of this FormElement, but with no annotations- Since:
- 2.10.6
-
getForm
public Form getForm()
Return the form this form element belongs to- Since:
- 2.0
-
getAnnotations
public List<WidgetAnnotation> getAnnotations()
Return a list of all the annotations associated with this form element. The list contains zero or moreWidgetAnnotationobjects, which may be accessed from this list or via the convenience methodgetAnnotation(int). The resulting list may have elements removed or reordered, although adding non-widget annotations, null objects or widgets from a different field will result in an Exception.- Since:
- 2.0 (prior to 2.0, this method returned an array of
PDFAnnotationobjects.
-
getAnnotation
public WidgetAnnotation getAnnotation(int annot)
Return the specified annotation. Identical togetAnnotations().get(annot)- Since:
- 2.0
-
getValue
public abstract String getValue()
Return the value for this element. Not all elements have a value returned by this method - for example, bothFormButtonandFormSignaturereturnnullfrom this method. See the method contract in each subclass for more detail.- Since:
- 2.0
-
getDescription
public String getDescription()
Return the text description of this field if specified, ornullif no description is supplied.- Since:
- 2.0
-
setDescription
public void setDescription(String s)
Set the text description of this field. Value may benullto remove it.- Since:
- 2.0
-
setAction
public void setAction(Event event, PDFAction action)
Set the action to perform when the specified event takes place on this field. Value events areEvent.KEYPRESS,Event.FORMAT,Event.CHANGEandEvent.OTHERCHANGE, which are the types of event that can take place on a FormElement. You may also want to checksetActionin theWidgetAnnotationclass to see events that are triggered on the fields annotation, rather than the field itself.- Parameters:
event- the event to place the action onaction- the action to invoke when the specified event takes place, ornullto remove the event.- Throws:
IllegalArgumentException- if the wrong type of event is set.- Since:
- 2.0
- See Also:
WidgetAnnotation.setAction(org.faceless.pdf2.Event, org.faceless.pdf2.PDFAction),Event
-
getAction
public PDFAction getAction(Event event)
Get the action that's performed when the specified event takes place on this field. Possible events are listed in thesetAction(org.faceless.pdf2.Event, org.faceless.pdf2.PDFAction)API docs.- Returns:
- the action associated with this event on this Form Element, or
nullif no action is specified for the event. - Since:
- 2.0
-
setReadOnly
public void setReadOnly(boolean readonly)
Set whether the field is read-only or not.- Parameters:
readonly- whether the field is read-only or not- Since:
- 1.1.23
-
isReadOnly
public boolean isReadOnly()
Get whether the field is read-only or not.- Returns:
- true if the field is read-only
- Since:
- 1.1.23
-
setRequired
public void setRequired(boolean required)
Set whether the field is required before the form is submitted. For some fields like pushbuttons, this method has no effect.- Parameters:
required- whether the field is a required field or not- Since:
- 1.1.23
-
isRequired
public boolean isRequired()
Get whether the field is required before the form is submitted. For some fields like pushbuttons, this method always returns false.- Returns:
- true if the field is required on form submission
- Since:
- 1.1.23
-
setSubmitted
public void setSubmitted(boolean submit)
Set whether the field is submitted or not. The default for every element in the form is true.- Parameters:
submit- whether the element is submitted or not.- Since:
- 1.1.23
-
isSubmitted
public boolean isSubmitted()
Get whether the field is submitted or not.- Returns:
- true if the field is submitted, false otherwise
- Since:
- 1.1.23
-
rebuild
public void rebuild()
Cause the annotation list to be rebuilt. Unless you're rendering the annotation using the viewer, it's not necessary to call this method.- Since:
- 2.8
-
flatten
public void flatten()
Flatten the form field so that the contents of it's annotation are permanently stamped on the page. The field's annotations are removed, but the field is not removed from the form - this must be done manually. Usually it's more convenient to flatten the entire form in one go, by calling theForm.flatten()method.- Since:
- 2.0
- See Also:
PDFAnnotation.flatten(),Form.flatten()
-
addPropertyChangeListener
public void addPropertyChangeListener(PropertyChangeListener l)
Add a PropertyChangeListener to this FormElement. Property changes will be fired when aspects of this FormElement are changed.
-
removePropertyChangeListener
public void removePropertyChangeListener(PropertyChangeListener l)
Remove a previously added PropertyChangeListener form this FormElement.- Since:
- 2.10.4
- See Also:
removePropertyChangeListener(java.beans.PropertyChangeListener)
-
toString
public String toString()
-
-