| java.lang.Object com.lowagie.text.pdf.BaseField com.lowagie.text.pdf.RadioCheckField
RadioCheckField | public class RadioCheckField extends BaseField (Code) | | Creates a radio or a check field.
Example usage:
Document document = new Document(PageSize.A4, 50, 50, 50, 50);
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("output.pdf"));
document.open();
PdfContentByte cb = writer.getDirectContent();
RadioCheckField bt = new RadioCheckField(writer, new Rectangle(100, 100, 200, 200), "radio", "v1");
bt.setCheckType(RadioCheckField.TYPE_CIRCLE);
bt.setBackgroundColor(Color.cyan);
bt.setBorderStyle(PdfBorderDictionary.STYLE_SOLID);
bt.setBorderColor(Color.red);
bt.setTextColor(Color.yellow);
bt.setBorderWidth(BaseField.BORDER_WIDTH_THICK);
bt.setChecked(false);
PdfFormField f1 = bt.getRadioField();
bt.setOnValue("v2");
bt.setChecked(true);
bt.setBox(new Rectangle(100, 300, 200, 400));
PdfFormField f2 = bt.getRadioField();
bt.setChecked(false);
PdfFormField top = bt.getRadioGroup(true, false);
bt.setOnValue("v3");
bt.setBox(new Rectangle(100, 500, 200, 600));
PdfFormField f3 = bt.getRadioField();
top.addKid(f1);
top.addKid(f2);
top.addKid(f3);
writer.addAnnotation(top);
bt = new RadioCheckField(writer, new Rectangle(300, 300, 400, 400), "check1", "Yes");
bt.setCheckType(RadioCheckField.TYPE_CHECK);
bt.setBorderWidth(BaseField.BORDER_WIDTH_THIN);
bt.setBorderColor(Color.black);
bt.setBackgroundColor(Color.white);
PdfFormField ck = bt.getCheckField();
writer.addAnnotation(ck);
document.close();
author: Paulo Soares (psoares@consiste.pt) |
Constructor Summary | |
public | RadioCheckField(PdfWriter writer, Rectangle box, String fieldName, String onValue) Creates a new instance of RadioCheckField
Parameters: writer - the document PdfWriter Parameters: box - the field location and dimensions Parameters: fieldName - the field name. |
TYPE_CHECK | final public static int TYPE_CHECK(Code) | | A field with the symbol check
|
TYPE_CIRCLE | final public static int TYPE_CIRCLE(Code) | | A field with the symbol circle
|
TYPE_CROSS | final public static int TYPE_CROSS(Code) | | A field with the symbol cross
|
TYPE_DIAMOND | final public static int TYPE_DIAMOND(Code) | | A field with the symbol diamond
|
TYPE_SQUARE | final public static int TYPE_SQUARE(Code) | | A field with the symbol square
|
TYPE_STAR | final public static int TYPE_STAR(Code) | | A field with the symbol star
|
RadioCheckField | public RadioCheckField(PdfWriter writer, Rectangle box, String fieldName, String onValue)(Code) | | Creates a new instance of RadioCheckField
Parameters: writer - the document PdfWriter Parameters: box - the field location and dimensions Parameters: fieldName - the field name. It must not be null Parameters: onValue - the value when the field is checked |
getAppearanceRadioCircle | public PdfAppearance getAppearanceRadioCircle(boolean on)(Code) | | Gets the special field appearance for the radio circle.
Parameters: on - true for the checked state, false otherwise the appearance |
getCheckType | public int getCheckType()(Code) | | Getter for property checkType.
Value of property checkType. |
getOnValue | public String getOnValue()(Code) | | Getter for property onValue.
Value of property onValue. |
getRadioGroup | public PdfFormField getRadioGroup(boolean noToggleToOff, boolean radiosInUnison)(Code) | | Gets a radio group. It's composed of the field specific keys, without the widget
ones. This field is to be used as a field aggregator with
PdfFormField.addKid(PdfFormField) addKid() .
Parameters: noToggleToOff - if true , exactly one radio button must be selected at alltimes; clicking the currently selected button has no effect.If false , clickingthe selected button deselects it, leaving no button selected. Parameters: radiosInUnison - if true , a group of radio buttons within a radio button field thatuse the same value for the on state will turn on and off in unison; that is ifone is checked, they are all checked. If false , the buttons are mutually exclusive(the same behavior as HTML radio buttons) the radio group |
isChecked | public boolean isChecked()(Code) | | Getter for property checked.
Value of property checked. |
setCheckType | public void setCheckType(int checkType)(Code) | | Sets the checked symbol. It can be
TYPE_CHECK ,
TYPE_CIRCLE ,
TYPE_CROSS ,
TYPE_DIAMOND ,
TYPE_SQUARE and
TYPE_STAR .
Parameters: checkType - the checked symbol |
setChecked | public void setChecked(boolean checked)(Code) | | Sets the state of the field to checked or unchecked.
Parameters: checked - the state of the field, true for checkedand false for unchecked |
setOnValue | public void setOnValue(String onValue)(Code) | | Sets the value when the field is checked.
Parameters: onValue - the value when the field is checked |
|
|