I want to create a onscreen keyboard such that when a text field gets focused the keyboard appears on the screen and when the focus is lost or if one clicks outside the screen the keyboard should disappear.
This is not the problem, the problem is that i’m not sure what I should use to create such a keyboard. I cannot use a jFrame because if I click outside the keyboard window then the keyboard goes to the background and is not closed. I also can’t use jDialog because it do not allow us to click outside the window.
I also would like to be able to show a textbox with what is entered by the keyboard in real-time(as i click the keys on the onscreen keyboard it should appear in the textbox). I am doing this program in netbeans so if you could keep that in mind, it would be helpful.
I am not sure I understand the requirement here, but see if this example gives you some ideas.
The basic thrust of it is to ensure there is ‘white space’ (OK
RED/ORANGEin this example, but let’s not quibble over shades of gray) around the components that can become focusable. Add a mouse listener to it, and on event, request the focus (or in your case, hide the keyboard).