textArea.append(message + "\n");  int newCaretPosition = textArea.getCaretPosition(); if (newCaretPosition == oldCaretPosition) { textArea.setCaretPosition(oldCaretPosition + (message + "\n").length());
SimpleAttributeSet attributes = new SimpleAttributeSet(); StyleConstants.setBackground(attributes, Color.WHITE); StyleConstants.setForeground(attributes, Color.BLACK); Document doc = textArea.getDocument(); String zeit = dateFormatter.format(new Date(System. currentTimeMillis())); try { doc.insertString(doc.getLength(), "[" + zeit + "]\t" + message + "\n", attributes); } catch (BadLocationException ex) { if (logger.isEnabledFor(Level.ERROR)){ logger.error("Fehler im IrcPlugin", ex); } } int newCaretPosition = textArea.getDocument().getLength(); if (newCaretPosition != oldCaretPosition) { textArea.setCaretPosition(newCaretPosition);
    public void updateTextArea(String message) {        int oldCaretPosition = textArea.getCaretPosition();        textArea.append(message + "\n");        int newCaretPosition = textArea.getCaretPosition();        if (newCaretPosition == oldCaretPosition) {            textArea.setCaretPosition(oldCaretPosition +                                      (message + "\n").length());        }    }