Solved

How to distinglish causes of Repaint events

Posted on 1998-01-02
1
404 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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

762 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

10 Experts available now in Live!

Get 1:1 Help Now