JTextPane.setCaretPostion

From: Patrick (burcht61_at_hotmail.com)
Date: 08/31/04


Date: 31 Aug 2004 05:01:23 -0700

Hello,

I have a JTextPane in a JScrollPane. My text contains 60000
characters. When moving the text to the JTextPane I set the
caretPosition to 0. This places the text top left at the first
position.

Now I want to set the caretPosition to 20000. This is the first
character of a line somewhere in the text. The scrollPane moves well
but it shows the line at the bottom of the scrollPane. I want it to
be the first visible line in the scrollPane, in other words position
20000 of the text must be in the top left corner of the scrollPane. I
searched for any example on the net, but I didn't found any.

How can I place the text correctly in the scrollPane ?

thanx for any answer.

Patrick.



Relevant Pages

  • JScrollBar/JTextPane: strange behaviour
    ... "textPane" embedded in a JScrollPane "scrollPane", ... I want to find out whether the JTextPane fits into the JScrollPane ... how can I find out the height of the textPane and extent of the scrollbar ...
    (comp.lang.java.gui)
  • ScrollPane Question
    ... I want to implement My own scrollpane for containing JTextPane. ... How my container will know that its child ...
    (comp.lang.java.gui)