tykkebror
asked on
Scrolling on a JPanel
Hi
i have the following applet : www.tykkebror.dk/scroll
source:
www.tykkebror.dk/scroll/ImagePanel.java
www.tykkebror.dk/scroll/JPanelScroll.java
The applet is just a JPanel with a scrollpane. I want the applet to scroll up and down the image when the mouse is near the edge. My only problem is that I cant get rid of the flickering. Everytime the image is scrolled it flickers or draws strange white lines across it. It doesnt matter if I use the "mouse near the edge thing" or I use the scrollbar it still destroys the graphic. My questions is:
1. Is there an easier more correct way to do the "mouse near the edge thing"?
2. How do I remove the flickering/white lines?
Comments on structure of code or other suggestion are most welcome.
Thx in advance :)
tykkebror
i have the following applet : www.tykkebror.dk/scroll
source:
www.tykkebror.dk/scroll/ImagePanel.java
www.tykkebror.dk/scroll/JPanelScroll.java
The applet is just a JPanel with a scrollpane. I want the applet to scroll up and down the image when the mouse is near the edge. My only problem is that I cant get rid of the flickering. Everytime the image is scrolled it flickers or draws strange white lines across it. It doesnt matter if I use the "mouse near the edge thing" or I use the scrollbar it still destroys the graphic. My questions is:
1. Is there an easier more correct way to do the "mouse near the edge thing"?
2. How do I remove the flickering/white lines?
Comments on structure of code or other suggestion are most welcome.
Thx in advance :)
tykkebror
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thx both of you
Changing the Applet to JApplet and removing the paint method from JPanelScroll sure removed some of the flickering.
Using the EventQueue.invokeLater() method to call ((JPanel)currentEvent.getS ource()).s crollRectT oVisible(s crollRect) ; removed the rest.
new applet: www.tykkebror.d/scroll/edit
new source:
www.tykkebror.dk/scroll/edit/ImagePanel.java
www.tykkebror.dk/scroll/edit/JPanelScroll.java
Thank you
Changing the Applet to JApplet and removing the paint method from JPanelScroll sure removed some of the flickering.
Using the EventQueue.invokeLater() method to call ((JPanel)currentEvent.getS
new applet: www.tykkebror.d/scroll/edit
new source:
www.tykkebror.dk/scroll/edit/ImagePanel.java
www.tykkebror.dk/scroll/edit/JPanelScroll.java
Thank you
ASKER
arrrrrgh why cant i edit my comments. Why cant I redo stuff.
My new applet url should be www.tykkebror.dk/scroll/edit
ohh and objects just posted twice ... same person :)
My new applet url should be www.tykkebror.dk/scroll/edit
ohh and objects just posted twice ... same person :)
This call should also be made from the event dispatch thread using EventQueue.invokeLater()