EDU.auburn.VGJ.gui
Class DragFix
java.lang.Object
|
+--EDU.auburn.VGJ.gui.DragFix
- All Implemented Interfaces:
- java.lang.Runnable
- public class DragFix
- extends java.lang.Object
- implements java.lang.Runnable
Drag fix queues events and eliminates repeated mouse
drag events and scrollbar events (most annoying on Win95).
Be sure the Component doesn't post an event to itself
after every mouse drag or scrollbar event, or this will do
no good. I suggest getParent().postEvent() instead.
The constructor for the Component that uses it should have
(to be safe, as the first line):
dragFix_ = new DragFix(this); // dragFix_ is a member variable.
The handleEvent() function should look like this:
public boolean handleEvent(Event e)
{
if(e.id == DragFix.QUEUED)
{
deal with (Event)e.arg
if necessary, super.handleEvent((Event)e.arg);
if necessary, getParent().postEvent((Event)e.arg);
return true;
}
dragFix_.queueEvent(e);
return true;
}
and removeNotify should look like this, to kill the thread
immediately - otherwise it will be there (asleep) until
finalize() gets called (if ever):
public synchronized void removeNotify()
{
dragFix_.killThread();
super.removeNotify();
}
Here is the source.
- Author:
- Larry Barowski
Field Summary |
static int |
QUEUED
|
Constructor Summary |
DragFix(java.awt.Component user)
|
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
QUEUED
public static final int QUEUED
DragFix
public DragFix(java.awt.Component user)
finalize
protected void finalize()
- Overrides:
finalize
in class java.lang.Object
killThread
public void killThread()
queueEvent
public void queueEvent(java.awt.Event e)
- Queue or ignore an event. Call this from handleEvent()
and return true.
run
public void run()
- Process queued events.
- Specified by:
run
in interface java.lang.Runnable