Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Want to know whether CAPS LOCK key is ON

 
Tapan Maru
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am developing a user management GUI in swing.
In that I am having a screen where user can change his password.

Now I want to display a POP Up message to the user if the CAPS LOCK key is ON when the any of the password field gets focused.

Is there any solution to this problem?
 
Srivatsa Katta
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Try getLockingKeyState(int keyCode) method from java.awt.Toolkit class.

where the key code for caps lock key is java.awt.event.KeyEvent.VK_CAPS_LOCK

-Srivatsa Katta
 
Tapan Maru
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Srivatsa

I have tried that code but I am getting UnSupportedOperationException when I run the code

I am trying the code on RedHat Linux 9..

Does it make any difference? Should I try out on Windows XP platform or on Solaris platform?

Tapan Maru
 
Tapan Maru
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Srivatsa

I have tried that code but I am getting UnSupportedOperationException when I run the code

I am trying the code on RedHat Linux 9..

Does it make any difference? Should I try out on Windows XP platform or on Solaris platform?
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
maybe this thread may interest you
 
Srivatsa Katta
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tapan,

I tried on windows OS its giving me the correct status. Am not sure about other platforms.

Regards,
Srivatsa Katta
 
Srivatsa Katta
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Is this how you are testing, this works fine on windows ideally it should work on all platforms.

stats is true if caps key is on, else false.

-Srivatsa Katta
 
Tapan Maru
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I have used it as the same way you have written the code!! But it is not working on the RedHat9 Linux.... I will try on Windows today so lets see....

Ideally it should work on all platforms (Java is platform independent....)
Anyways, thanks for the help, keep posting....
 
Tapan Maru
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes it is working in Windows XP fine at my side also. Lets see if I can get any solution!!!
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!