Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds


  Asked By: Hamish    Date: Feb 11    Category: Java    Views: 546

I'm using a JEditorPane attached to a JEdtorScrollPane to render html content
for a little chat applet.
I'm having two problems with these two:

1. convince the jeditorpane to wrap the html content to it's physical size.
2. always keep the editorpane scrolled to the bottom, so that the last phrases
are always visible...

Is it possible what I'm trying to do ?



3 Answers Found

Answer #1    Answered By: Edfu Massri     Answered On: Feb 11

On Question 2:
To keep the editorpane scrolled to the bottom, use the method
setCaretPosition to the length of the text in it.

public void setCaretPosition(int position)


Answer #2    Answered By: Samuel Costa     Answered On: Feb 11

As an unexpected (at least for me) behaviour, the editorpane.getText()
method seems to return
the size  of the whole HTML source, while the setCaretPosition() only seems
to count the 'visible' text only (that is no tags or newlines).

Answer #3    Answered By: Dirck Jansen     Answered On: Feb 11

Not so sure about the Visibility thing, but to scoll down everytime,
one way would be to select some text in the bottom of the
pane. You can even select zero length, i.e no text in the end of
your page after calling pane's set page.

Didn't find what you were looking for? Find more on JEditorPane Or get search suggestion and latest updates.