my dog learned polymorphism*
The moose likes Beginning Java and the fly likes Disable Key Input in a J frame Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Disable Key Input in a J frame" Watch "Disable Key Input in a J frame" New topic
Author

Disable Key Input in a J frame

Koh Khai Huat
Ranch Hand

Joined: Aug 05, 2005
Posts: 100
Hi guys,

I have a question I notice that java standard edition have some function of disabling user input from keyboard and Mouse but i can not get any info of this topic.... so i am asking if anyone of you have a link or a sample code please let me know i need some clue on this topic i don't know where to start searching no this topic and don't know where to start looking i have been reading books but i don't find anything that is related to what i am trying to find...

if you guys have any link that is related to this topic or any book that have info on this please let me know a big thanks in advance

regards
KKH


if (!WorkHard){
System.out.println("Fail!!!");
}
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
disabling key/mouse is do-able, but is it necessary?
perhaps you are using the wrong components to display data.

can you be a bit more specific on what you are trying to accomplish?

also, you may getter a better response if you post this in the swing forum
Justin Fox
Ranch Hand

Joined: Jan 24, 2006
Posts: 802
umm, graphics wise, you can do JComponent.isEnabled(false);

i dont know why you'd want to disable the mouse?

not very user friendly..

like say you connect, or the action your doing is turn based,

you can use the isEnabled() fuction to help you out..

Justin

by the way?...

say i have a gameBoard class...

can i extend JComponent, so i can use it's isEnabled, and other

neat methods?


You down with OOP? Yeah you know me!
Koh Khai Huat
Ranch Hand

Joined: Aug 05, 2005
Posts: 100
Hi guys,

May be i put it in a wrong way.... I am trying to write a J2SE code to disable the user Mouse and Key Board input... My aim is just for trying it out as i am quite interested on how java can disable the user Input from mouse or keyboard..... so i have search some of the books and online but i don't get what i am looking for....

so I would like to ask if you all have any link on this topic or have any books that talk about this topic please let me know a very big thanks in advance =D

sorry fot the confiusion =(

regards
KKH
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
this might be one of the ways

Koh Khai Huat
Ranch Hand

Joined: Aug 05, 2005
Posts: 100
Hi Michael Dunn,

Thanks for the sample code it really works thanks again for your help...

correct me if i am wrong.. what you did was let the Jframe receive the input from the key board and then do nothing... but if the Jframe is not in focus then the method would not work already....

But i was thinking if is it possible to disable the user Mouse and Key board with out using a Jframe... for example like calling some API to disable the user Input with out using the Jframe....

thanks for your help thank you very much.... =D

regards
KKH
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
you're talking about disabling keyboard/mouse at an OS level?

if so, I'm not sure that can be done from java.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24168
    
  30

Originally posted by koh khai huat:
calling some API to disable the user Input with out using the Jframe....


Try this:

System.out.println("HEY USER: DON'T TOUCH THE MOUSE OR KEYBOARD! THANKS!");

Seriously, though: if you don't have a window, then you're not going to get any mouse input anyway. As Michael says, if you're trying to lock the screen for the whole desktop, then you're not going to be able to do that from pure Java (at least without, one way or another, throwing up a window.)


[Jess in Action][AskingGoodQuestions]
Koh Khai Huat
Ranch Hand

Joined: Aug 05, 2005
Posts: 100
Hi Michael Dunn and Ernest Friedman-Hill,

Thanks for all the help i get the idea now thank you very much thanks alot =D

regards
KKH
 
wood burning stoves
 
subject: Disable Key Input in a J frame
 
Similar Threads
What are EJB related security annotations in Java EE 6?
How to know from where and when user copy the text?
Passed SCJP1.4 with 88%
Servlets or not?
Client side soap message handlers