* a string representing the line to be printed
* @param type
* The logical format type.
*/
private void handleAddLine(final String header, final String line, final NotificationType type) {
final JScrollBar vbar = scrollPane.getVerticalScrollBar();
final int currentLocation = vbar.getValue();
setAutoScrollEnabled((vbar.getValue() + vbar.getVisibleAmount() == vbar.getMaximum()));
insertNewline();
final java.text.Format formatter = new java.text.SimpleDateFormat("[HH:mm] ");
final String dateString = formatter.format(new Date());
insertTimestamp(dateString);
insertHeader(header);
insertText(line, type);
// wait a bit so that the scroll bar knows where it should scroll
SwingUtilities.invokeLater(new Runnable() {
public void run() {
if (isAutoScrollEnabled()) {
scrollToBottom();
} else {
// the scroll bar insists changing its value, so jump back.
// in a sane toolkit it would be possible to defer drawing
// until this
vbar.setValue(currentLocation);
setUnreadLinesWarning(true);
}
}
});
}