OK, so the easiest way is to extend the JTextPane. The advanced class created and managed the base list. If you change the format (for example, new colors), the list will completely reformat the data. The only real problem was that autoscrolling is not 100% reliable, Both:
Container parent = getParent(); // get the parent until scroll pane is found while (parent != null && !(parent instanceof JScrollPane)) { parent = parent.getParent(); } if (parent != null) { JScrollPane scrollPane = (JScrollPane)parent; scrollPane.getVerticalScrollBar().setValue(scrollPane.getVerticalScrollBar().getMaximum()); }
and
scrollRectToVisible(new Rectangle(0, getHeight() - 2, 1, 1));
Provide inconsistent results when the text panel sometimes does not scroll completely.
source share