CheckBoxWidgetAnnotation Class
A widget annotation associated with a check box form field.
Declaration
public class CheckBoxWidgetAnnotation extends WidgetAnnotation
Remarks
The following code snippet creates a checkbox field:
import com.devexpress.drawing.*;
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);
float y = 750;
float step = 30;
float textHeight = 14f;
// Create a check box field and add it to the field collection.
CheckBoxField agreeField = new CheckBoxField("AgreeToTerms");
pdfDocument.getFields().add(agreeField);
// Bind the check box field to a widget and place it on the page.
RectangleF agreeBounds = new RectangleF(50, y - textHeight + 6, 18, 18);
CheckBoxWidgetAnnotation agreeWidget = new CheckBoxWidgetAnnotation(agreeField, agreeBounds);
page.getAnnotations().add(agreeWidget);
y -= step;
// Add a label for the check box field.
TextFragment label = new TextFragment();
label.setText("Agree to terms");
label.setLocation(new PointF(
agreeBounds.getX() + 30,
agreeBounds.getY() + 6));
page.getFragments().add(label);
// 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 Checkbox.
Inherited Members
Inheritance
CheckBoxWidgetAnnotation(FormField formField, RectangleF bounds)
Initializes a new instance of the CheckBoxWidgetAnnotation class with specified settings.
Declaration
public CheckBoxWidgetAnnotation(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. |
Methods
getButtonStyle() Method
Returns the style used to draw the check box button.
Declaration
public FormFieldButtonStyle getButtonStyle()
Returns
| Type | Description |
|---|---|
| FormFieldButtonStyle | The style used to draw the check box button. |
getShouldGeneratePressedAppearance() Method
Returns whether a pressed appearance is generated for the widget annotation.
Declaration
public boolean getShouldGeneratePressedAppearance()
Returns
| Type | Description |
|---|---|
| boolean |
|
setButtonStyle(FormFieldButtonStyle value) Method
Sets the check box button style.
Declaration
public void setButtonStyle(FormFieldButtonStyle value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | FormFieldButtonStyle | The check box button style. |
setShouldGeneratePressedAppearance(boolean value) Method
Sets whether to generate a pressed appearance for the widget annotation.
Declaration
public void setShouldGeneratePressedAppearance(boolean value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | boolean |
|