请参考以下代码:
JavaScriptAction javascipt_action = new JavaScriptAction(Action.create(form.getDocument(),
Action.e_TypeJavaScript));
javascipt_action.setScript("var annot = this.addAnnot({ page : 0, type : \"Square\", rect : [ 0, 0, 100, 100 ], name :
\"UniqueID\", author : \"A. C. Robat\", contents : \"This section needs revision.\" });");
AdditionalAction aa = new AdditionalAction(field);
aa.setAction(AdditionalAction.e_TriggerAnnotCursorEnter, javascipt_action);
aa.doJSAction(AdditionalAction.e_TriggerAnnotCursorEnter);