Skip to main content

ListBoxWidgetAnnotation Class

A widget annotation associated with a list box form field.

Declaration

public class ListBoxWidgetAnnotation extends WidgetAnnotation

Remarks

The following code snippet creates a list box field:

import com.devexpress.docs.pdf.*;
import com.devexpress.system.drawing.*;
import com.devexpress.drawing.printing.DXPaperKind;

import java.nio.channels.*;
import java.nio.file.*;

public class Main {
    public static void main(String[] args) throws Exception {
        try (PdfDocument pdfDocument = new PdfDocument()) {
            // Add an A4 page to the document.
            Page page = pdfDocument.getPages().add(DXPaperKind.A4);

            // Create a list box field.
            ListBoxField field = new ListBoxField("Country");

            // Add list items.
            field.getItems().add(new ChoiceFieldItem("USA"));
            field.getItems().add(new ChoiceFieldItem("Canada"));
            field.getItems().add(new ChoiceFieldItem("Germany"));
            field.getItems().add(new ChoiceFieldItem("France"));
            field.getItems().add(new ChoiceFieldItem("UK"));
            field.getItems().add(new ChoiceFieldItem("Italy"));
            field.getItems().add(new ChoiceFieldItem("Spain"));

            pdfDocument.getFields().add(field);

            // Bind the field to a widget.
            ListBoxWidgetAnnotation widget =
                    new ListBoxWidgetAnnotation(
                            field,
                            new RectangleF(20, 640, 120, 70));

            page.getAnnotations().add(widget);

            // Save the document.
            try (WritableByteChannel channel =
                     FileChannel.open(Path.of("result.pdf"),
                         StandardOpenOption.CREATE,
                         StandardOpenOption.WRITE,
                         StandardOpenOption.TRUNCATE_EXISTING)) {

                pdfDocument.save(channel);
            }
        }
    }
}

Refer to the following help topic for additional information: Create a List Box.

Inherited Members

com.devexpress.system.JavaObject.clone()
com.devexpress.system.JavaObject.equals(java.lang.Object)
com.devexpress.system.JavaObject.hashCode()
com.devexpress.system.JavaObject.memberwiseClone()
com.devexpress.system.JavaObject.toString()
java.lang.Object.finalize()
java.lang.Object.getClass()
java.lang.Object.notify()
java.lang.Object.notifyAll()
java.lang.Object.wait()
java.lang.Object.wait(long)
java.lang.Object.wait(long,int)

Inheritance

Object
JavaObject
BaseAnnotation
WidgetAnnotation
ListBoxWidgetAnnotation

ListBoxWidgetAnnotation(FormField formField, RectangleF bounds)

Initializes a new instance of the ListBoxWidgetAnnotation class with specified settings.

Declaration

public ListBoxWidgetAnnotation(FormField formField, RectangleF bounds)

Parameters

Name Type Description
formField FormField

The form field associated with the widget annotation.

bounds RectangleF

The bounds of the widget annotation on the page.