Solved

Disable event

Posted on 2002-07-25
4
245 Views
Last Modified: 2010-03-31
Does any one know how to disable AWT event, or to catch these event before them processed.
Thanks
0
Comment
Question by:semion50
4 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 25 total points
ID: 7177113
You can call consume() on the event for a localised treatment, but you may want to disable that sort of event before it is even generated - it depends on what you want to do.
0
 
LVL 4

Assisted Solution

by:kylar
kylar earned 25 total points
ID: 7178108
To disable all AWT events (which is a bad idea, since RepaintEvents are kind of needed (to *see* components).. you can create your own event queue like this:

public class EventQueueOverrider extends java.awt.EventQueue{
   static{
        Toolkit.getDefaultToolkit().getSystemEventQueue().push(new EventQueueOverrider());
   }
 
   public void dispatchEvent(AWTEvent event){
      System.out.println("Event caught.. ignoring");
   }

}

if you do that, then all your events will be ignored. You can parse out the events that you really want to stop, like MouseEvents or something, then let the rest pass through to the queue with a call to super.dispatchEvent().

Do some reading on event types and how they're executed first though, since the example I showed you will pull up an empty frame (no paint events get passed...)

Cheers,
Kylar
0
 
LVL 35

Expert Comment

by:girionis
ID: 8952123
No comment has been added lately, so it's time to clean up this TA.

I will leave a recommendation in the Cleanup topic area that this question is:

- split points between CEHJ and kylar

Please leave any comments here within the
next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

girionis
Cleanup Volunteer
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
how to add new optional parameter to JSP 1 40
java stored proc example 9 29
Configure a Bean in an XML file 4 31
how to see all occupied ports on windows 10 laptop 15 59
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

816 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

9 Experts available now in Live!

Get 1:1 Help Now