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.

Variable Index

 o QUEUED

Constructor Index

 o DragFix(Component)

Method Index

 o finalize()
 o killThread()
 o queueEvent(Event)
Queue or ignore an event.
 o run()
Process queued events.

Variables

 o QUEUED
  public final static int QUEUED

Constructors

 o DragFix
  public DragFix(Component user)

Methods

 o finalize
  protected void finalize()
Overrides:
finalize in class Object
 o killThread
  public void killThread()
 o queueEvent
  public void queueEvent(Event e)
Queue or ignore an event. Call this from handleEvent() and return true.
 o run
  public synchronized void run()
Process queued events.

All Packages  Class Hierarchy  This Package  Previous  Next  Index