The only way to make it works in ALL circumstances is the following setting:
setBorder (BorderFactory.createLineBorder (new Color (0, 0, 0, 0), 2));
otherwise (when you have null background of the parent container) you will see the "I" cursor remaining forever at the left edge of your JTextField. (Simply make some tests for different border thickness and observe quite strange way the JTextField places the cursor when you activate it first time.)
Alternatively you can set:
setBorder (BorderFactory.createLineBorder (getBackground (), 2));
but you will obtain the field opticaly larger by 2 pixels in all four directions. If you don't specify the border thickness, you will see the cursor BETWEEN this border and the field remaining forever.