Class EDU.auburn.VGJ.gui.DragFix
All Packages Class Hierarchy This Package Previous Next Index
Class EDU.auburn.VGJ.gui.DragFix
java.lang.Object
|
+----EDU.auburn.VGJ.gui.DragFix
- public class DragFix
- extends Object
- implements 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.
-
QUEUED
-
-
DragFix(Component)
-
-
finalize()
-
-
killThread()
-
-
queueEvent(Event)
- Queue or ignore an event.
-
run()
- Process queued events.
QUEUED
public final static int QUEUED
DragFix
public DragFix(Component user)
finalize
protected void finalize()
- Overrides:
- finalize in class Object
killThread
public void killThread()
queueEvent
public void queueEvent(Event e)
- Queue or ignore an event. Call this from handleEvent()
and return true.
run
public synchronized void run()
- Process queued events.
All Packages Class Hierarchy This Package Previous Next Index