/** Add annotation to the document. For annotation of whole line * the length parameter can be ignored (specify value -1). * @param doc the document which will be annotated * @param startPos position which represent begining * of the annotated text * @param length length of the annotated text. If -1 is specified * the whole line will be annotated * @param annotation annotation which is attached to this text * @since 1.20 */ public static void addAnnotation (final StyledDocument doc, final Position startPos, final int length, final Annotation annotation) { if (!(doc instanceof Annotatable)) return; if (SwingUtilities.isEventDispatchThread()) { ((Annotatable)doc).addAnnotation (startPos, length, annotation); } else { SwingUtilities.invokeLater(new Runnable() { public void run() { ((Annotatable)doc).addAnnotation (startPos, length, annotation); } }); } }
/** Removal of added annotation. * @param doc the annotated document * @param annotation annotation which is going to be removed * @since 1.20 */ public static void removeAnnotation (final StyledDocument doc, final Annotation annotation) { if (!(doc instanceof Annotatable)) return; if (SwingUtilities.isEventDispatchThread()) { ((Annotatable)doc).removeAnnotation (annotation); } else { SwingUtilities.invokeLater(new Runnable() { public void run() { ((Annotatable)doc).removeAnnotation (annotation); } }); } }
/** Add annotation to the document. For annotation of whole line * the length parameter can be ignored (specify value -1). * @param doc the document which will be annotated * @param startPos position which represent begining * of the annotated text * @param length length of the annotated text. If -1 is specified * the whole line will be annotated * @param annotation annotation which is attached to this text * @since 1.20 */ public static void addAnnotation (final StyledDocument doc, final Position startPos, final int length, final Annotation annotation) { if (!(doc instanceof Annotatable)) return; if (SwingUtilities.isEventDispatchThread()) { ((Annotatable)doc).addAnnotation (startPos, length, annotation); } else { SwingUtilities.invokeLater(new Runnable() { public void run() { ((Annotatable)doc).addAnnotation (startPos, length, annotation); } }); } }
/** * Add annotation to the document. For annotation of whole line * the length parameter can be ignored (specify value -1). * <br/> * Note: since 6.35 the requests (delegated to document) are no longer replanned to EDT. * @param doc the document which will be annotated * @param startPos position which represent begining * of the annotated text * @param length length of the annotated text. If -1 is specified * the whole line will be annotated * @param annotation annotation which is attached to this text * @since 1.20 */ public static void addAnnotation( final StyledDocument doc, final Position startPos, final int length, final Annotation annotation ) { if (!(doc instanceof Annotatable)) { return; } ((Annotatable) doc).addAnnotation(startPos, length, annotation); }
/** Removal of added annotation. * @param doc the annotated document * @param annotation annotation which is going to be removed * @since 1.20 */ public static void removeAnnotation (final StyledDocument doc, final Annotation annotation) { if (!(doc instanceof Annotatable)) return; if (SwingUtilities.isEventDispatchThread()) { ((Annotatable)doc).removeAnnotation (annotation); } else { SwingUtilities.invokeLater(new Runnable() { public void run() { ((Annotatable)doc).removeAnnotation (annotation); } }); } }
public void run() { ((Annotatable)doc).addAnnotation (startPos, length, annotation); } });
/** * Removal of added annotation. * <br/> * Note: since 6.35 the requests (delegated to document) are no longer replanned to EDT. * @param doc the annotated document * @param annotation annotation which is going to be removed * @since 1.20 */ public static void removeAnnotation(final StyledDocument doc, final Annotation annotation) { if (!(doc instanceof Annotatable)) { return; } ((Annotatable) doc).removeAnnotation(annotation); }
public void run() { ((Annotatable)doc).addAnnotation (startPos, length, annotation); } });
public void run() { ((Annotatable)doc).removeAnnotation (annotation); } });
public void run() { ((Annotatable)doc).removeAnnotation (annotation); } });