• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to know "PrintScreen" button pressed ????

 
Sumeet Pandit
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I need to capture the event on "PrintScreen" or to disable "PrintScreen" button. How can I capture the event on the button? How Come I know that "PrintScrren" button is pressed?
Your help in the same will be highly appreciated....Plz help this is very important..
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The KeyEvent class has a key code called VK_PRINTSCREEN that represents the PrintScreen key...

To listen for it being pressed you would write a keylistener something like this...


And then attach this listener to whatever component is concerned with catching key presses on the printscreen key.

-Nate
 
Sumeet Pandit
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Nathan,
Thanks for your reply..
But the code is not working with keyPressed Event, It works with keyReleased Event.With keyReleased, the event fires after the PrintScreen action completed. We need it to trap PrintScreen Button at the time of keyPressed....
Plz help me to trap the PrintScreen action.
Thanks in advance.
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looked in the Java Bug database... looks like you can't detect anything other than keyReleased on the print screen key on Windows, since the Windows OS doesn't produce a KEY_DOWN message for it...

(Here's the bug report if you are interested.)

-Nate
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!