Solved

How to distinglish causes of Repaint events

Posted on 1998-01-02
1
407 Views
Last Modified: 2010-05-18
Does anybody know within the callback method
"paint(Graphics)", how can we distinglish between whether it
is ...
a) Caused by component movement (e.g. when I drag a
   component over other components)
OR
b) Caused by window exposure (e.g. when I drag another
   window over my applet)

For yr background information, I need to distinglish
them and handle in a different way in order to support drag
& drop of components in my applet.

In the moving component in case (a), I need to erase the
current location before I draw and on a new location.  I
also use myGraphics.setXORMode(..) to ensure it doesn't
erase its path.

In case (b), I just erase the whole applet and redraw it.

Best regards,
Ricky
0
Comment
Question by:hori
1 Comment
 
LVL 4

Accepted Solution

by:
russgold earned 50 total points
ID: 1231923
The AWT does not support any way to tell why paint is being called; generally, if you are trying to minimize repainting, you keep an offscreen bitmap and just copy it to the screen during paint.

The best that you can do is to keep track of your own invalidations and recompute those areas only.  For an example of how this might work, check:

http://www.netaxs.com/~russgold/java_samples/dragTest.html

which includes a JDK 1.02-compatible drag-and-drop demo that I wrote a while ago.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
groupNoAdj 7 83
Groovy:unable to resolve class error 2 65
print map entry 34 53
Spring Framework HTTPSession management 1 21
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

947 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now