[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Scrolling on a JPanel

Posted on 2006-07-23
4
Medium Priority
?
1,157 Views
Last Modified: 2012-06-27
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
0
Comment
Question by:tykkebror
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 92

Accepted Solution

by:
objects earned 800 total points
ID: 17164366
In JPanelScroll use a JApplet instead of an Applet
And don't override paint()
0
 
LVL 92

Expert Comment

by:objects
ID: 17164375
>                     ((JPanel)currentEvent.getSource()).scrollRectToVisible(scrollRect);

This call should also be made from the event dispatch thread using EventQueue.invokeLater()


0
 

Author Comment

by:tykkebror
ID: 17164749
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.getSource()).scrollRectToVisible(scrollRect); 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
0
 

Author Comment

by:tykkebror
ID: 17164779
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 :)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question