Button Class | CheckBox Class | ComboBox Class | ListBox Class | RadioButton Class |  TextField Class | JavaScriptAction Class | Programming with Generator for Java

Welcome > Generator > Programming > Interactive Forms

An interactive form—sometimes referred to as an AcroForm—is a collection of fields for gathering information interactively from the user. A PDF document may contain any number of fields, appearing on any combination of pages, all of which make up a single, global interactive form spanning the entire document.


Field Types

Interactive forms support the following field types:

Button Form Field

This example shows how to create a Button and add it to the page.


[Java]
    Button button = new Button( "Button Name", 50, 50, 100, 50 );
    button.setAction(new JavaScriptAction( "app.alert('Hello');" ));
    button.setBackgroundColor(RgbColor.getAliceBlue());
    button.setBehavior(Behavior.createPush( "downLabel", "rolloverLabel" ));
    button.setBorderColor(RgbColor.getBlueViolet());
    button.setBorderStyle(BorderStyle.BEVELED);
    button.setLabel("Push");
    button.setTextColor(RgbColor.getDarkGreen());
    button.setToolTip("Click");

Check Box Form Field

This example shows how to create an Check Box and add it to the page.


[Java]
    CheckBox checkBox = new CheckBox( "Check Box Name", 5, 7, 50, 50 );
    checkBox.setDefaultChecked(true);
    checkBox.setToolTip("Check it");

Combo Box Form Field

This example shows how to create a Combo Box and add it to the page.


[Java]
    ComboBox comboBox = new ComboBox( "Combo Box Name", 50, 75, 150, 25 );
    comboBox.addItem( "One" );
    comboBox.addItem( "Two" );
    comboBox.addItem( "Three" );
    comboBox.setBackgroundColor(RgbColor.getAliceBlue());
    comboBox.setBorderColor(RgbColor.getDarkMagenta());
    comboBox.setDefaultChoice("One");
    comboBox.setEditable(true);
    comboBox.setToolTip("Select");

List Box Form Field

This example shows how to create a List Box and add it to the page.


[Java]
    ListBox listBox = new ListBox( "List Box Name", 5, 2, 100, 150 );
    listBox.addItem( "One" );
    listBox.addItem( "Two" );
    listBox.addItem( "Three" );
    listBox.setBackgroundColor(RgbColor.getAliceBlue());
    listBox.setBorderColor(RgbColor.getDarkMagenta());
    listBox.setBorderStyle(BorderStyle.DASHED);
    listBox.setDefaultChoice("One");
    listBox.setMultiselect(true);
    listBox.setToolTip("Select");

Radio Button Form Field

This example shows how to create a Radio Button and add it to the page.


[Java]
    RadioButton radio1 = new RadioButton( "Radio Button Name", 50, 25, 100, 75 );
    radio1.setDefaultChecked(true);
    radio2.setExportValue("abc");
    radio1.setToolTip("first");
    RadioButton radio2 = new RadioButton( "Radio Button Name", 50, 140, 100, 75 );
    radio2.setExportValue("def");
    radio2.setToolTip("second");
    RadioButton radio3 = new RadioButton( "Radio Button Name", 50, 250, 100, 75 );
    radio3.setExportValue("ghi");
    radio3.setToolTip("third");

Text Form Field

This example shows how to create a Text Field and add it to the page.


[Java]
    TextField textField = new TextField( "Text Field Name", 50, 75, 150, 100 );
    textField.setTextAlign(Align.CENTER);
    textField.setBackgroundColor(RgbColor.getAliceBlue());
    textField.setBorderColor(RgbColor.getDeepPink());
    textField.setFont(Font.getTimesItalic());
    textField.setFontSize(16.0f);
    textField.setTextColor(RgbColor.getBrown());
    textField.setDefaultValue("ceTe Software");
    textField.setMultiLine(true);
    textField.setToolTip("Text");

See Also 

Button Class | CheckBox Class | ComboBox Class | ListBox Class | RadioButton Class |  TextField Class | JavaScriptAction Class | Programming with Generator for Java