I'm using a JEditorPane attached to a JEdtorScrollPane to render html contentfor 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 phrasesare always visible...Is it possible what I'm trying to do ?
On Question 2:To keep the editorpane scrolled to the bottom, use the methodsetCaretPosition to the length of the text in it.public void setCaretPosition(int position)editorpane.setCaretPosition(editorpane.getText().length());
As an unexpected (at least for me) behaviour, the editorpane.getText()method seems to returnthe size of the whole HTML source, while the setCaretPosition() only seemsto count the 'visible' text only (that is no tags or newlines).
Not so sure about the Visibility thing, but to scoll down everytime,one way would be to select some text in the bottom of thepane. You can even select zero length, i.e no text in the end ofyour page after calling pane's set page.