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?
# 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();}
}
# 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.