adding scrollbars to canvas!!
hi everybody,
a have a simple ?
i'm working on a chat application. my message displaying area is a canvas.i have added scroll-bars to it using scroll-pane
"sp = new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS);"
now what i want is the scrollbars should adjust automatically to
display the last message and also i should be able to adjust them
manually so that i can view the previous messages.
i have tried setScrollposition() it works well also but then i'm not
able to adjust scrollbars manually.
this interface is in AWT.
please tell me a solution.its a bit urgent.
thankx and regards
asheet
[688 byte] By [
asheet] at [2007-9-26 3:54:40]

Seems like you have created a bug. If you call setScrollPositon() when new text is added to the bottom of your Canvas (I assume this makes the Canvas grow), Then you should still be able to scroll up again manually.
Maybe the problem is that you call setScrollPosition() too often? This is my suggestion: If scrollposition is at the bottom, and new text is added then (and only then) you call setScrollPosition.
";-)
Ragnvald Barth
Software engineer
http://blake.prohosting.com/ragnvald/
Because your canvas is growing.(I think)
The new size of the canvas causes it to be layd out again. And laying out a component usually causes flickering (depending on the plattform). I guess the workaround would be to use a canvas just as big as the shown part of it. Add a scrollbar by its side (not a scrollpane) and use the scrollposition to choose what part of the text that should be painted. That way you can use doublebuffering, and avoid the problem completly. (No resizing of components means nothing is layd out again)
";-)
Ragnvald Barth
Software engineer