[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.newcomer] Re: Getting scroll pane to display bottom of text (using Swing)
|
In article <dj2q3o$p3s$1@xxxxxxxxxxxxxxxx>, yaofahua@xxxxxxxxxxx (Jack
Yao) wrote:
> *From:* Jack Yao <yaofahua@xxxxxxxxxxx>
> *Date:* Tue, 18 Oct 2005 20:34:20 +0800
>
> Peter Toye wrote:
> > I'm trying to get JTextArea in a JSCrollPane to display the latest
> > text after I use append. Whatever I do it seems to scroll up to the
> > top of the area, which isn't very useful. Thanks in advance for any
> > help.
> >
> > The code I've got (very much cut down of course is:
> >
> > JTextArea textArea = new JTextArea();
> > JScrollPane scrollPane = new JScrollPane(textArea);
> > .
> > .
> > .
> > textArea.append("various bits of data\n");
> > scrollPane.scrollRectToVisible(new Rectangle(0,textArea.getHeight
> > ()-scrollPane.getHeight(),
> > scrollPane.getWidth(),scrollPane.getHeight()));
> >
> > scrollPane.validate();
> >
> > Peter
>
> Hope this can help you :
> http://java.sun.com/docs/books/tutorial/uiswing/components/scrollpane.ht
> ml
> --
> JACK YAO, Beijing, China
>
Thanks, Jack.
I've already read this and I thought that I was doing what it told me to.
That's why I'm a bit puzzled.
Peter