The sample below shows how to change the select cursor on annotations components. This done by adding a IPDFListener to the PDFNotesBean and implementing the method afterDocOpened(). In this method, the cursor of annotations components is changed to the predefined hand cursor.
PDFNotesBean notesBean = new PDFNotesBean(); // !! This is important to ensure that annotations components are created when the document is loaded // instead of waiting till a page is rendered. notesBean.setIncrementalLoad(false); notesBean.addPDFListener(new IPDFListener() { @Override public void afterDocOpened(PDFNotesBean notesBean, String docName, File pdfFile) { IPDFDocument pdfDoc = notesBean.getDocument(); for (int i = 0; i < pdfDoc.getPageCount(); ++i) { try { Vector<Annotation> annots = pdfDoc.getIPage(i).getAnnotations(); if (annots != null) { for (int j = 0; j < annots.size(); ++j) { if (annots.get(j).getComponent() != null) { annots.get(j).getComponent().setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } } } } catch (PDFException e) { e.printStackTrace(); } } } @Override public void annotModified(PDFNotesBean notesBean, Annotation annot, int pageIndex) { } @Override public void annotDeleted(PDFNotesBean notesBean, Annotation annot, int pageIndex) { } @Override public void annotAdded(PDFNotesBean notesBean, Annotation newAnnot, IPDFPage pdfPage, int pageIndex) { } @Override public void afterDocSaved(PDFNotesBean notesBean, String docName, File pdfFile) { } @Override public void afterDocClosed(PDFNotesBean notesBean) { } }); |