'How to make JTextField lose its focus?
Exacly as stated in the subject how to make JTextField lose its focus?
Something like:
jtf.setFocus(false)
Solution 1:[1]
You could simply transfer focus to another component:
myOtherComponent.requestFocusInWindow();
Solution 2:[2]
You may call requestFocus() method from another control
Solution 3:[3]
One can also focus on a panel so that it would look like no components were focused
jpanel1.requestFocusInWindow();
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | Usman Salihin |
| Solution 3 | HALO |
