Window ancestor = getAncestorWindow();
Component currentFocus = ancestor.getCurrentFocus();
if ( currentFocus != this) {
EventQueue evtQueue =
Toolkit.getDefaultToolkit().getSystemEventQueue();
FocusEvent evt = new FocusEvent(AWTEvent.FOCUS_LOST, currentFocus);
evtQueue.postEvent(evt);
evt = new FocusEvent(AWTEvent.FOCUS_GAINED, this);
evtQueue.postEvent(evt);
// if (getParent() != null)
getParent().setFocus(this);