
Signature
~~~ Rifletti, prima di pensare! ~~~
> why is this being ignored..
>
> textAreaTop.setAlignmentY(textAreaTop.BOTTOM_ALIGNMENT)
>
> have tried to use this method a no. of times, it never works.. what other
> way is there, pls, to set text alignment.. thank you..
> that's not for *text* alignment
> maybe this can help:
> http://forum.java.sun.com/thread.jspa?forumID=57&threadID=390611
thank you very much... here's relevant code from url you posted:
SimpleAttributeSet attrs=new SimpleAttributeSet();
StyleConstants.setAlignment(attrs,StyleConstants.ALIGN_CENTER);
StyledDocument doc=(StyledDocument)edit.getDocument();
doc.insertString(0,"111\n2222222\n33333333333333",attrs);
doc.setParagraphAttributes(0,doc.getLength()-1,attrs,false);
however, this is for a chat window... how do I do it so all messages get
typed at bottom of JTextPane? (I mean at bottom of JTextPane but one
msg underneath the previous one.. standard chat window behavior..)
w/this code, this code won't do that, will it?
actually my boss said it would be ok if msgs appear at top of window,
but the problem w/that is that if there are a lot of msgs in that top
JTextPane you can't see msgs at bottom (beyond height of JTextPane..) I
do have a scroll bar, but have to scroll down to see msgs, normally in
chat windows you can always see the last msg that was sent... in my
case you can only see it if you scroll down.. this is only reason why
wanted to put msgs at the bottom of JTextPane (and afterwards might have
same scroll problem anyway..) is there a way to config scrolling
behavior to do what I need? thank you very much for help..
pb - 07 Oct 2005 16:05 GMT
you can scroll with:
scrollPane.getViewport().scrollRectToVisible(.....);
in combination with SwingUtilities.convertRectangle(...) to obtain the
correct Rectangle
I used to scroll at the right point (my scrollpane had a serie of panels,
but perhaps you can adjust it for your case).
or you can try (nont tested):
txtArea.setCaretPosition( txtArea.getText().length() )
> actually my boss said it would be ok if msgs appear at top of window, but
> the problem w/that is that if there are a lot of msgs in that top
[quoted text clipped - 5 lines]
> problem anyway..) is there a way to config scrolling behavior to do what I
> need? thank you very much for help..
Frances - 07 Oct 2005 19:50 GMT
> you can scroll with:
> scrollPane.getViewport().scrollRectToVisible(.....);
[quoted text clipped - 4 lines]
>
> or you can try (nont tested):
> txtArea.setCaretPosition( txtArea.getText().length() )
this last one worked!! thank you!! :)