public void updateTextArea(String message) { updateTextArea(message, true);
public void updateTextArea(String message, boolean withTimeStamp) { Document doc = textArea.getDocument(); int oldCaretPosition = textArea.getCaretPosition(); SimpleAttributeSet attributes = new SimpleAttributeSet(); StyleConstants.setBackground(attributes, Color.WHITE); StyleConstants.setForeground(attributes, Color.BLACK); int index = message.indexOf('>'); String compareValue; boolean eigenerName = false; boolean doMark = false; if (index!=-1 && message.length()-1>index){ compareValue = message.substring(index+1); } else{ compareValue = message; } if (compareValue.indexOf(parentPanel.getNickname())!=-1){ StyleConstants.setBackground(attributes, Color.ORANGE); eigenerName = true; doMark = true; } else if (message.indexOf("---> JOIN:")!=-1){ StyleConstants.setForeground(attributes, Color.GREEN); } else if (message.indexOf("<--- PART:")!=-1){ StyleConstants.setForeground(attributes, Color.RED); } else if (message.indexOf("<--- QUIT:")!=-1){ StyleConstants.setForeground(attributes, Color.RED); } else if (!withTimeStamp || index==-1){ StyleConstants.setForeground(attributes, Color.GRAY); } else{ StyleConstants.setForeground(attributes, Color.BLACK); doMark = true; } try{ if (withTimeStamp) { String zeit = dateFormatter.format(new Date(System. currentTimeMillis())); doc.insertString(doc.getLength(), "[" + zeit + "]\t" + message + "\n", attributes); } else { doc.insertString(doc.getLength(), message + "\n", attributes); } } catch(BadLocationException blE){ if (logger.isEnabledFor(Level.ERROR)){ logger.error("Fehler im IrcPlugin", blE); } } if (!selected && doMark){ if (eigenerName){ for (int i = 0; i < tabbedPane.getTabCount(); i++) { Object tab = tabbedPane.getComponentAt(i); if (tab == this) { tabbedPane.setForegroundAt(i, Color.GREEN); } } } if (!eigenerName && !marked){ for (int i = 0; i < tabbedPane.getTabCount(); i++) { Object tab = tabbedPane.getComponentAt(i); if (tab == this) { tabbedPane.setForegroundAt(i, Color.RED); } } } marked = true; } int newCaretPosition = doc.getLength(); if (newCaretPosition != oldCaretPosition){ textArea.setCaretPosition(newCaretPosition); }
    public void updateTextArea(String message) {        updateTextArea(message, true);    }