I have a frame, which contains a button & a textfild. Clicking on the button I am displaying a JOptionPane. Once the JOptionPane gets closed the focus should be in text field. I am requesting the focus on the textfield after JOptionPane.showMessageDialog(). I have added focus listeners to Button & textfield on the frame. In focusLost method i am getting the opposite component of the component which lost the focus.
Step to reproduce
------------------
1) Run the attached program.
2) Click on the Button. You will see a JOptionPane. The opposite component of the button on the frame is JOptionPane "OK" button. Oberve on the console that "button focus gained " & "button focus lost" message is displayed. And opposite component of button on the frame is "OK" button of Joptionpane.
3) Click on the "OK" button of JOptionPane. The JOptionPanen gets close. Observe on the console that textfield(tf) gains the focus & lose the focus. its opposite component is null. This is incorrect textfield is not suppose to gain the focus.
but the focus goes to "Button & loses the focus And later goes to textfield. , which is the correct behaviour.
This works fine in solaris , but fails in window xp. I tested this in jdk6.0 & jdk7.0.