Solved

Disable event

Posted on 2002-07-25
4
243 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This video teaches viewers about errors in exception handling.

763 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

7 Experts available now in Live!

Get 1:1 Help Now