Scrollpane and scrolling down
From: LongBow (kejerhag_at_yahoo.com)
Date: 04/29/04
- Next message: beachnut: "System Menu Icon Question"
- Previous message: Andrew Thompson: "Re: Text-Componente with fixed width but variable height"
- Next in thread: Andrew Thompson: "Re: Scrollpane and scrolling down"
- Reply: Andrew Thompson: "Re: Scrollpane and scrolling down"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 29 Apr 2004 17:03:14 +0200
Hi!
I have a problem with scrolling. I have a JScrollPane with a JTextPane
inside it. Adding text to the textpane is done through a StyledDocument.
There are two functions adding text to the doc (with two different styles).
The problem is that I want the scrollpane to automatically scroll down to
the bottom of all text when text is added. It works fine as long as only one
function is adding text, but as soon as the other starts adding the
"auto"-scrolling doesnt work anymore. I have tried a lot methods, but no one
seems to be working. Can anyone tell me how it should be done?
I have something like this:
JTextPane historyPanel = new JTextPane();
JScrollPane jScrollPane1 = new JScrollPane();
StyledDocument doc = historyPanel.getStyledDocument();
jScrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NE
EDED);
jScrollPane1.getViewport().add(historyPanel, null);
And adding is done through
doc.insertString(doc.getLength(),text,styleMe);
and
doc.insertString(doc.getLength(),text,styleHe);
Thanks in advance!
/ Morgan
- Next message: beachnut: "System Menu Icon Question"
- Previous message: Andrew Thompson: "Re: Text-Componente with fixed width but variable height"
- Next in thread: Andrew Thompson: "Re: Scrollpane and scrolling down"
- Reply: Andrew Thompson: "Re: Scrollpane and scrolling down"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|