import java.io.*;
import com.lowagie.text.*;
import com.lowagie.text.pdf.*;
import java.awt.Color;

public class CheckBoxTable {
    
    public static void main(String[] args) {
        try {
            Document document = new Document(PageSize.A4, 50, 50, 50, 50);
            PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("c:\\CheckBoxTable.pdf"));
            document.open();
            PdfPTable t = new PdfPTable(2);
            t.addCell("A check box on the right");
            PdfPCell c = new PdfPCell();
            c.setMinimumHeight(40);
            c.setCellEvent(new BoxEvent(writer));
            t.addCell(c);
            document.add(t);
            document.close();
        }
        catch(Exception de) {
            de.printStackTrace();
        }
        System.out.println("Finished!");
    }
    
    public static class BoxEvent implements PdfPCellEvent {
        private PdfWriter writer;
        
        public BoxEvent(PdfWriter writer) {
            this.writer = writer;
        }
        
        public void cellLayout(PdfPCell cell, Rectangle position, PdfContentByte[] canvases) {
            try {
                RadioCheckField rf = new RadioCheckField(writer, new Rectangle(position.left() + 5, position.bottom() + 5, position.right() - 5, position.top() - 5), "MyBox", "Yes");
                rf.setCheckType(RadioCheckField.TYPE_CHECK);
                rf.setBorderWidth(BaseField.BORDER_WIDTH_THICK);
                rf.setBorderColor(Color.black);
                rf.setChecked(true);
                PdfFormField ff = rf.getCheckField();
                writer.addAnnotation(ff);
            }
            catch (Exception e) {
                throw new ExceptionConverter(e);
            }
        }        
    }
}