Want to know whether CAPS LOCK key is ON

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?

[303 byte] By [tapan_javaprogrammera] at [2007-11-27 7:58:25]
# 1

class Testing

{

public Testing()

{

System.out.println("Caps lock on = "+

java.awt.Toolkit.getDefaultToolkit().getLockingKeyState(java.awt.event.KeyEvent.VK_CAPS_LOCK));

}

public static void main(String[] args){new Testing();}

}

Michael_Dunna at 2007-7-12 19:40:20 > top of Java-index,Desktop,Core GUI APIs...
# 2
Thanks MichaelI have tried that code but I am getting UnSupportedOperationException when I run the codeI 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_javaprogrammera at 2007-7-12 19:40:20 > top of Java-index,Desktop,Core GUI APIs...
# 3
not sure what you should do - I'll wait to see what response you get at JavaRanch before spending any more time on it.
Michael_Dunna at 2007-7-12 19:40:20 > top of Java-index,Desktop,Core GUI APIs...
# 4
> I have tried that code but I am getting UnSupportedOperationException when I run the codeDid you try reading the API?
camickra at 2007-7-12 19:40:20 > top of Java-index,Desktop,Core GUI APIs...
# 5

"Did you try reading the API?"

Yes I have tried reading the API but did not get any idea why it happens. According to the API, there are two reasons why UnSupportedOperationException:

1) If the host system doesnt allow getting the state of this key programatically OR

2) if the key board doesnt have the key

Now I am sure that there is a CAPS LOCK key available on my keyboard.

please guide me about the first reason as I think I am not understands the first reason....

waiting for your relpy with explanation at the earliest.

tapan_javaprogrammera at 2007-7-12 19:40:20 > top of Java-index,Desktop,Core GUI APIs...
# 6
> please guide me about the first reason as I think I am not understands the first reason....It means its not supported.It works on my machine. I use Windows XP.
camickra at 2007-7-12 19:40:20 > top of Java-index,Desktop,Core GUI APIs...