Search code examples
javaswingfocusjtextfield

Make Focus Not Go To The First Component


In one article I read that by default focus will go to the first component on the Window. And it is doing like this. My first component is JTextField.

The problem: I want that the focus goes nowhere when the program is started. I want that at the beginning of the program there is no focus anywhere.

How could I do this?


Solution

  • Actually Your, nimsson, idea almost worked. At least it gave me the right direction to find out the answer by myself.

    I called requestFocusInWindow(false) method on my frame and now the focus is gone.