Reputation: 11920
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.
Upvotes: 0
Views: 1137
Reputation: 71
recordTP = new JTextPane();
recordTP.setText(" from client:");
recordTP.setEditable(false);
DefaultCaret caret = (DefaultCaret)recordTP.getCaret();
caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
Upvotes: 0
Reputation: 324118
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.
Upvotes: 3