int newCaretPosition = textArea.getDocument().getLength(); if (newCaretPosition != oldCaretPosition) { textArea.setCaretPosition(newCaretPosition); }
    public void updateTextArea(String message) {        int oldCaretPosition = textArea.getCaretPosition();        String zeit = dateFormatter.format(new Date(System.            currentTimeMillis()));        textArea.append("[" + zeit + "]\t" + message + "\n");        int newCaretPosition = textArea.getCaretPosition();        if (newCaretPosition == oldCaretPosition) {            textArea.setCaretPosition(oldCaretPosition +                                      (message + "\n").length());        }        if (!selected && !marked){            marked = true;            for (int i = 0; i < tabbedPane.getTabCount(); i++) {                Object tab = tabbedPane.getComponentAt(i);                if (tab == this) {                    tabbedPane.setForegroundAt(i, Color.GREEN);                }            }        }    }