Hey folks... Got a Java + Swing problem and design question here. I am currently writing a Jabber client in Java. Everything is going well, except one part. The conversation window.
What I have is a JEditorPane in a JScrollPane. The scrollbar should always be at the bottom of the JEditorPane text, because in an IM client, that's the text that came in last, which is the text you haven't looked at yet, right? The problem with a JEditorPane is that you cannot "append" text to it, only set what text is displayed. This means that the ScrollBar resets back to the top when you reset the text in the editorpane. So, you might think, why not just set the scrollbar to the bottom after I set the text? First... most of the time the scrollbar gets set to the bottom before the JEditorPane is done doing it's thing by setting the text, so for an instant the scrollbar is at the bottom, and then goes back to the top. So, you might think, why not just use invokeLater or a short Timer? Because then there is a noticeably ugly jump of the scrollbar to the top when the text is set, and then back to the bottom. My question is: is there something I am missing? Some other way I should be going about this (in Java, for those of you who are going to say "go about it in another language")? My design question is once I get all this straightened out and it works right, how would I go about implementing a way that the scrollbar only scrolls to the end on a new message if the scrollbar is already at the end (so that if someone scrolls to the top, they aren't interrupted by a new message)? Thanks in advance, Adam Olsen ____________________ BYU Unix Users Group http://uug.byu.edu/ ___________________________________________________________________ List Info: http://uug.byu.edu/cgi-bin/mailman/listinfo/uug-list
