customized KeyboardFocusManager problems with JOptionPane-Dialogs
Hi,
I have a problem I'm not able to solve: With Java 1.4.2 unter Linux, as well as all newer Java Versions (1.4, 1.5, 1.6) under Windows, dialogs created by JOptionPane.showXXXDialog do not react to keyboard events like <Tab> any more when using a customized KeyboardFocusManager. Java 1.5 and 1.6 under Linux work fine.
Here is what I did:
I have a JFrame and want some customized focus control when navigating through the Frame with <Tab>. Therefore I've implemented a class
publicclass EfaFrameFocusManagerextends DefaultKeyboardFocusManagere
and said in the main JFrame:
EfaFrameFocusManager myFocusManager =new EfaFrameFocusManager(this,FocusManager.getCurrentKeyboardFocusManager());
FocusManager.setCurrentKeyboardFocusManager(myFocusManager);
The constructor of my EfaFrameFocusManager stores the JFrame (this) and the original KeyboardFocusManager (2nd arg) for later use. Within my own FocusManager, I've implemented the method
publicvoid processKeyEvent(Component cur, KeyEvent e)
which is checking whether the desired Frame (efaFrame) is currently active or not. If it is active, it's performing my customized operations which is working well. If it is not active (e.g. because a dialog created with JOptionPane.showConfirmDialog() is open), it should perform default actions. So I said within processKeyEvent:
if (!efaFrame.isActive()){// efaFrame is the previous "this" arg
fm.processKeyEvent(cur,e);// fm is the previously stored CurrentKeyboardFocusManager
return;
}
Instead of invoking processKeyEvent on the original KeyboardFocusManager fm, I also tried super.processKeyEvent(cur,e);
, but without any change in behavior.
As I said before, this is working well under Java 1.5 and 1.6 with Linux.
However, it isnot working unter Windows (any Java version I tried, including 1.4, 1.5 and 1.6) and also not unter Linux with Java 1.4. With these combinations, dialogs created by JOptionPane.showXXXDialog(...) do not respond to the <Tab> key. I do see that my own FocusManagers processKeyEvent method is invoked, and I also see that it invokes the one of the original FocusManager, but the Dialog doesn't react.
What am I doing wrong?
Nick.

