|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.faceless.pdf2.FormElement
org.faceless.pdf2.FormRadioButton
public final class FormRadioButton
A type of form element representing a Radio Button, which can be either "checked" or "cleared" (on or off), in the same way as the HTML "radiobutton" input type. Unlike Checkboxes, at least one annotation for each Radio Button must be set.
Here's an example showing how to add a set of RadioButtons to a form
FormRadioButton ccard = new FormRadioButton(); ccard.addAnnotation("Mastercard", page, 100, 100, 110, 110); ccard.addAnnotation("Visa", page, 120, 100, 130, 110); ccard.addAnnotation("Amex", page, 140, 100, 150, 110); form.addElement("CreditCard", ccard);
and here's how to determine which of those values is checked
Form form = pdf.getForm(); FormRadioButton ccard = (FormRadioButton)form.getElement("CreditCard"); String value = ccard.getValue(); // May be null if none are checked
Constructor Summary | |
---|---|
FormRadioButton()
Create a new FormRadioButton element. |
Method Summary | |
---|---|
WidgetAnnotation |
addAnnotation(String value,
PDFPage page,
float x1,
float y1,
float x2,
float y2)
Add an annotation to the Checkbox or RadioButton. |
String |
getDefaultValue()
Return the default value of this field, or null |
Map |
getOptions()
Return a read-only Map containing the values (annotations) that can be selected in this RadioButton or Checkbox. |
String |
getValue()
Get the value of this field. |
boolean |
isNoToggleToOff()
Return true if the "NoToggleToOff" flag is set, which means it should not be possible to set the value of this field to null by clicking on an already selected Radio Button. |
boolean |
isRadiosInUnison()
Return true if the "RadiosInUnison" flag is set, which means fields with the same value are all turned on or off in unison (if one is chcked, they are all checked). |
void |
rebuild()
Cause the annotation list to be rebuilt. |
void |
setDefaultValue(String value)
Set the default value for this field. |
void |
setRadiosInUnison(boolean flag)
Set the value of the "RadiosInUnison" flag, as returned by isRadiosInUnison() |
void |
setValue(String value)
Mark the specified annotation for the Checkbox/RadioButton as selected, and unselect any others. |
String |
toString()
|
Methods inherited from class org.faceless.pdf2.FormElement |
---|
addPropertyChangeListener, duplicate, flatten, getAction, getAnnotation, getAnnotations, getDescription, getForm, isReadOnly, isRequired, isSubmitted, removePropertyChangeListener, setAction, setDescription, setReadOnly, setRequired, setSubmitted |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public FormRadioButton()
addAnnotation(java.lang.String, org.faceless.pdf2.PDFPage, float, float, float, float)
method.
Method Detail |
---|
public boolean isRadiosInUnison()
public void setRadiosInUnison(boolean flag)
isRadiosInUnison()
public void setValue(String value)
value
of one of this field's
WidgetAnnotation
objects, otherwise an an
IllegalArgumentException
is thrown.
value
- the value of the annotation to select, or null
to turn them all offpublic void setDefaultValue(String value)
PDFAction.formReset()
action is invoked. See setValue(java.lang.String, java.lang.String)
for a
discussion of which values are valid.
value
- the value of the annotation to select, or null
to turn them all offpublic String getValue()
null
if no annotation is selected.
null
if none is selectedpublic String getDefaultValue()
null if no
default value exists.
- Returns:
- the default value of this field, or
null
if none is specified
public Map getOptions()
FormElement.getAnnotations()
,
this method is not strictly necessary, but it's a little more convenient
and intuitive so we've left it in.
public void rebuild()
FormElement
public boolean isNoToggleToOff()
public WidgetAnnotation addAnnotation(String value, PDFPage page, float x1, float y1, float x2, float y2)
value
- the value of the annotation - this will be the value returned
by getValue()
if this annotation is selected. Note that "Off" is not
allowed as an annotation name.page
- the page to place the annotation onx1
- the left-most X co-ordinate of the annotationy1
- the top-most Y co-ordinate of the annotationx2
- the right-most X co-ordinate of the annotationy2
- the bottom-most Y co-ordinate of the annotationpublic String toString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |