开发者

Problem with JTextPane - cursor Position at the end

I have a JTextpane that I had populated it from DB.

The problem is when I set text, and when it's long, the JTextPane show the text from the end like in the snapshot.

How can I do ?? I tried setCursor() but I seem it isn't the right method.

开发者_JAVA技巧

Problem with JTextPane - cursor Position at the end


You can do something like:

JTextPane textPane = new JTextPane();
DefaultCaret caret = (DefaultCaret)textPane.getCaret();
caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
textPane.setText(...);

See Text Area Scrolling for more info.


recordTP = new JTextPane();
    recordTP.setText(" from client:");
    recordTP.setEditable(false);
    DefaultCaret caret = (DefaultCaret)recordTP.getCaret();
    caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜