Example #1
0
  // Update the box that shows current actions.
  public void updateGUI(String message) {
    StyledDocument text = updateBox.getStyledDocument();
    SimpleAttributeSet currentWords = new SimpleAttributeSet();
    StyleConstants.setBold(currentWords, true);
    SimpleAttributeSet pastWords = new SimpleAttributeSet();
    StyleConstants.setBold(pastWords, false);

    try {
      text.setCharacterAttributes(0, text.getLength(), pastWords, true);
      text.insertString(0, message + "\n", currentWords);
    } catch (BadLocationException e) {
      // TODO Auto-generated catch block
      System.err.println("Bad location exception while styling updateBox.");
      e.printStackTrace();
    }

    updateBox.setCaretPosition(0);
  }