Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Disable event

Posted on 2002-07-25
4
Medium Priority
?
253 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 100 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 100 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses

885 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