Solved

Disable event

Posted on 2002-07-25
4
248 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

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

Suggested Solutions

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
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…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses

752 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