Problem with JScrollPane + Canvas
I'm using a class MyCanvas that extended java.awt.canvas.
An object of class MyCanvas is included inside a JScrollPane object with the methods getViewport().add(Component comp,int index).
The obj MyCanvas shows correctly the image inside, but the JScrollPane obj doesn't scroll automatically. Why ? Is it possible ?
Each scrollbar of JScrollPane obj is setting to AS_NEEDED policy.
Plz help me.
[434 byte] By [
lambu76] at [2007-9-26 7:02:56]

Your using JScrollPane and I don't know if this solution will work with JScrollPane because my application uses a ScrollPane. You can test it and if doesn't work you could replace the JScrollPane with a ScrollPane if you wanted to. You firstly set the size of your canvas to something big so something like canvas.setSize(5000,5000) for example. You then add your canvas to the ScrollPane with something like scrollPane.add(canvas) and then making sure you've set the scrollbar policy to something like ALWAYS or WHEN_NEEDED you should see scrollbars and be able to scroll them.
PS: In the ScrollPane control you set the scrollbar policy in the constructor.
I hope this works for you.