将select定位在最后即可
代码只有一行,如下://假设你的JTextPane名字为jChatArea//定位在最后,获得滚轮自动定位尾端效果
jChatArea.select(jChatArea.getText().length(),jChatArea.getText().length());

解决方案 »

  1.   

    jChatArea.setCaretPosition(jChatArea.getText().length());这个方法怎么样也可以的。
    但它和.select()差不多,每次jChatArea内容改变就得自己调用它来刷新,不怎么爽。
    ------------------------------------------------------------------------------
    JDK里的注释:
    Sets the position of the text insertion caret for the TextComponent. Note that the caret tracks change, so this may move if the underlying text of the component is changed. If the document is null, does nothing. The position must be between 0 and the length of the component's text or else an exception is thrown.
    ============================================================