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]
# 1

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/

Ragnvald at 2007-6-29 12:44:03 > top of Java-index,Desktop,Core GUI APIs...
# 2
thanx for ur reply.but the problem is still there once u call that setscrollposition() method u can not move the scrollbar manually.please help..asheet
asheet at 2007-6-29 12:44:03 > top of Java-index,Desktop,Core GUI APIs...
# 3
hi Ragnvald ,i have solved that prolem.i dot need ur help any more i have done it on my own.but thanx for ur advice.asheet
asheet at 2007-6-29 12:44:03 > top of Java-index,Desktop,Core GUI APIs...
# 4

hi Ragnvald ,

i have solved that prolem.i dot need ur help any more i have done it on my own.but thanx for ur advice.now whenever i am moving the scrollbar no flickering is happening but whenever new text is added and scrollbar position is moved it happens(Flickering) why?

asheet

asheet at 2007-6-29 12:44:03 > top of Java-index,Desktop,Core GUI APIs...
# 5

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

Ragnvald at 2007-6-29 12:44:03 > top of Java-index,Desktop,Core GUI APIs...
# 6
i am facing same problem pls tell me how u solved it .thanksRahul
r4ahul at 2007-6-29 12:44:03 > top of Java-index,Desktop,Core GUI APIs...