The Artima Developer Community
Sponsored Link

Java Answers Forum
disabling the keyevents

3 replies on 1 page. Most recent reply: Aug 18, 2004 10:03 PM by gaurav

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 3 replies on 1 page
gaurav

Posts: 12
Nickname: goravtomar
Registered: Jul, 2004

disabling the keyevents Posted: Aug 15, 2004 11:14 PM
Reply to this message Reply
Advertisement
the problem iam facing is that, my application has several screens and each screen change occurs after pressing <spacebar>, i have to execute a function xyz() that runs for 1 min at the 3rd screen. The problem is that while the func xyz() is exec. if someone presses the <spacebar> the keyevent getstored on the queue and as soon as the func exited it gets handled, how could i stop the events from being enqueued.


mausam

Posts: 243
Nickname: mausam
Registered: Sep, 2003

Re: disabling the keyevents Posted: Aug 16, 2004 8:50 PM
Reply to this message Reply
Try keyEvent.consume() and see if it help

Varanasi R Pushpeswar

Posts: 6
Nickname: ravieswar
Registered: May, 2004

Re: disabling the keyevents Posted: Aug 18, 2004 4:41 AM
Reply to this message Reply
hi gourav,
there is another way to stop listening to keystrokes using remove___listener ok
this is the efficient way of handling events
from
V.R.Eswar
varanasi_eswar2003@yahoo.com
or
varanasieswar@hotmail.com

gaurav

Posts: 12
Nickname: goravtomar
Registered: Jul, 2004

Re: disabling the keyevents Posted: Aug 18, 2004 10:03 PM
Reply to this message Reply
i don't know how but this is happening that even after removing the listener when i re-add it it starts handeling all the previous events.
i don't know but as soon as the handeler is added the handler starts handling the events that are fired in between the remove and the next add_listener().
i have solved the problem by consuming the events.
but i'll be highly thankfull if u could tell me something about the disableEvents().
i have tried the above but wasn't successfull, i tried using it to disable keyevnts from delievering to the frame(the frame was also the listener).

the pseudo code was as follows:-
class abc extends frame implements KeyListener,Mouselistener{
public abc(){
.
.
addKeylistener(this);
.
.
addMouselistener(this);
.
.
}
public static void main(_){
.
.
.
}
.
.
public void keypressed(KeyEvent k){
_.println(k.toString());
}
.
.
public void mouseclicked(Mouseevent me){
this.disableevnts(KeyEvent.KEY_EVENT_MASK);
}
.
.
}


after even clicking the frame the events are delivered to the frame.

Thanx for your patience and time and the nice suggestion.

Flat View: This topic has 3 replies on 1 page
Topic: Protected Inner Classes Previous Topic   Next Topic Topic: volume controller

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use