Solved

How to distinglish causes of Repaint events

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone 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

Suggested Solutions

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

856 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