• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Disable Key Input in a J frame

 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 802
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Koh Khai Huat
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
this might be one of the ways

 
Koh Khai Huat
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you're talking about disabling keyboard/mouse at an OS level?

if so, I'm not sure that can be done from java.
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.)
 
Koh Khai Huat
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Doe, a deer, a female deer. Ray, a pockeful of sun. Me, a name, I call my tiny ad ...
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic