Solved

How to distinglish causes of Repaint events

Posted on 1998-01-02
1
409 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Checkbox and ListView in Android Layout 4 65
simple java question 3 55
Error trying to install RTMT Win7 5 59
going to wrong jsp page 2 19
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
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 learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
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 …

785 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