during investigation of 6458497 I have found that we have similar problems (in term of focus transfer) under X. Here is a simple test to reproduce the problem.
You need to press "press me" button and transfer focus out of the java.
import java.awt.AWTEvent;
import java.awt.FlowLayout;
import java.awt.Toolkit;
import java.awt.event.AWTEventListener;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.WindowConstants;
/**
*
* @author son
*/
public class bug6458497 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
JFrame jframe = new JFrame("test for 6458497") {
public String toString() {
return "frame1";
}
};
jframe.setLayout(new FlowLayout());
JButton jbtn1 = new JButton("press me") {
public String toString() {
return "button1";
}
};
jframe.add(jbtn1);
final JButton jbtn2 = new JButton("I'm going to have a focus") {
public String toString() {
return "button2";
}
};
jframe.add(jbtn2);
jframe.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
jframe.pack();
jbtn1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
System.err.println("Got action, waiting...");
try {
Thread.sleep(3000);
} catch (InterruptedException ex) {
ex.printStackTrace();
}
System.err.println("requesting focus on jbtn2... " + jbtn2.requestFocus(false));
}
});
jframe.setVisible(true);
JFrame jframe2 = new JFrame("an opposite frame") {
public String toString() {
return "frame2";
}
};
jframe2.add(new JButton("jbutton") {
public String toString() {
return "button3";
}
});
jframe2.pack();
jframe2.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
jframe2.setVisible(true);
}
}