Examples: Style property (RichTextRange - Java)

This agent toggles between blue and red the color of the text content of the first table in the current document.

import lotus.domino.*;

public class JavaAgent extends AgentBase {

  public void NotesMain() {

    try {
      Session session = getSession();
      AgentContext agentContext = session.getAgentContext();

      // (Your code goes here) 
      DocumentCollection dc = agentContext.getUnprocessedDocuments();
      Document doc = dc.getFirstDocument();
      RichTextItem body = (RichTextItem)doc.getFirstItem("Body");
      RichTextNavigator rtnav = body.createNavigator();
      if (rtnav.findFirstElement(RichTextItem.RTELEM_TYPE_TABLE)) {
        RichTextRange rtrange = body.createRange();
        rtrange.setBegin(rtnav);
        rtrange.setEnd(rtnav);
        RichTextStyle style = rtrange.getStyle();
        if (style.getColor() == RichTextStyle.COLOR_BLUE)
          style.setColor(RichTextStyle.COLOR_RED);
        else
          style.setColor(RichTextStyle.COLOR_BLUE);
        rtrange.setStyle(style);
        doc.save(true, true);
      }
      else
        System.out.println("Body does not contain any tables");

    } catch(Exception e) {
      e.printStackTrace();
    }
  }
}