Java Code Examples for java.awt.event.FocusEvent#FOCUS_GAINED
The following examples show how to use
java.awt.event.FocusEvent#FOCUS_GAINED .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Util.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
private static boolean trackEvent(int eventID, Component comp, Runnable action, int time, boolean printEvent) { EventListener listener = null; switch (eventID) { case WindowEvent.WINDOW_GAINED_FOCUS: listener = wgfListener; break; case FocusEvent.FOCUS_GAINED: listener = fgListener; break; case ActionEvent.ACTION_PERFORMED: listener = apListener; break; } listener.listen(comp, printEvent); action.run(); return Util.waitForCondition(listener.getNotifier(), time); }
Example 2
Source File: Util.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
private static boolean trackEvent(int eventID, Component comp, Runnable action, int time, boolean printEvent) { EventListener listener = null; switch (eventID) { case WindowEvent.WINDOW_GAINED_FOCUS: listener = wgfListener; break; case FocusEvent.FOCUS_GAINED: listener = fgListener; break; case ActionEvent.ACTION_PERFORMED: listener = apListener; break; } listener.listen(comp, printEvent); action.run(); return Util.waitForCondition(listener.getNotifier(), time); }
Example 3
Source File: KeyboardFocusManagerPeerImpl.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("deprecation") public static boolean deliverFocus(Component lightweightChild, Component target, boolean temporary, boolean focusedWindowChangeAllowed, long time, CausedFocusEvent.Cause cause, Component currentFocusOwner) // provided by the descendant peers { if (lightweightChild == null) { lightweightChild = target; } Component currentOwner = currentFocusOwner; if (currentOwner != null && currentOwner.getPeer() == null) { currentOwner = null; } if (currentOwner != null) { FocusEvent fl = new CausedFocusEvent(currentOwner, FocusEvent.FOCUS_LOST, false, lightweightChild, cause); if (focusLog.isLoggable(PlatformLogger.Level.FINER)) { focusLog.finer("Posting focus event: " + fl); } SunToolkit.postEvent(SunToolkit.targetToAppContext(currentOwner), fl); } FocusEvent fg = new CausedFocusEvent(lightweightChild, FocusEvent.FOCUS_GAINED, false, currentOwner, cause); if (focusLog.isLoggable(PlatformLogger.Level.FINER)) { focusLog.finer("Posting focus event: " + fg); } SunToolkit.postEvent(SunToolkit.targetToAppContext(lightweightChild), fg); return true; }
Example 4
Source File: KeyboardFocusManagerPeerImpl.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("deprecation") public static boolean deliverFocus(Component lightweightChild, Component target, boolean temporary, boolean focusedWindowChangeAllowed, long time, CausedFocusEvent.Cause cause, Component currentFocusOwner) // provided by the descendant peers { if (lightweightChild == null) { lightweightChild = target; } Component currentOwner = currentFocusOwner; if (currentOwner != null && currentOwner.getPeer() == null) { currentOwner = null; } if (currentOwner != null) { FocusEvent fl = new CausedFocusEvent(currentOwner, FocusEvent.FOCUS_LOST, false, lightweightChild, cause); if (focusLog.isLoggable(PlatformLogger.Level.FINER)) { focusLog.finer("Posting focus event: " + fl); } SunToolkit.postEvent(SunToolkit.targetToAppContext(currentOwner), fl); } FocusEvent fg = new CausedFocusEvent(lightweightChild, FocusEvent.FOCUS_GAINED, false, currentOwner, cause); if (focusLog.isLoggable(PlatformLogger.Level.FINER)) { focusLog.finer("Posting focus event: " + fg); } SunToolkit.postEvent(SunToolkit.targetToAppContext(lightweightChild), fg); return true; }
Example 5
Source File: KeyboardFocusManagerPeerImpl.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("deprecation") public static boolean deliverFocus(Component lightweightChild, Component target, boolean temporary, boolean focusedWindowChangeAllowed, long time, CausedFocusEvent.Cause cause, Component currentFocusOwner) // provided by the descendant peers { if (lightweightChild == null) { lightweightChild = target; } Component currentOwner = currentFocusOwner; if (currentOwner != null && currentOwner.getPeer() == null) { currentOwner = null; } if (currentOwner != null) { FocusEvent fl = new CausedFocusEvent(currentOwner, FocusEvent.FOCUS_LOST, false, lightweightChild, cause); if (focusLog.isLoggable(PlatformLogger.Level.FINER)) { focusLog.finer("Posting focus event: " + fl); } SunToolkit.postEvent(SunToolkit.targetToAppContext(currentOwner), fl); } FocusEvent fg = new CausedFocusEvent(lightweightChild, FocusEvent.FOCUS_GAINED, false, currentOwner, cause); if (focusLog.isLoggable(PlatformLogger.Level.FINER)) { focusLog.finer("Posting focus event: " + fg); } SunToolkit.postEvent(SunToolkit.targetToAppContext(lightweightChild), fg); return true; }
Example 6
Source File: KeyboardFocusManagerPeerImpl.java From hottub with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("deprecation") public static boolean deliverFocus(Component lightweightChild, Component target, boolean temporary, boolean focusedWindowChangeAllowed, long time, CausedFocusEvent.Cause cause, Component currentFocusOwner) // provided by the descendant peers { if (lightweightChild == null) { lightweightChild = target; } Component currentOwner = currentFocusOwner; if (currentOwner != null && currentOwner.getPeer() == null) { currentOwner = null; } if (currentOwner != null) { FocusEvent fl = new CausedFocusEvent(currentOwner, FocusEvent.FOCUS_LOST, false, lightweightChild, cause); if (focusLog.isLoggable(PlatformLogger.Level.FINER)) { focusLog.finer("Posting focus event: " + fl); } SunToolkit.postEvent(SunToolkit.targetToAppContext(currentOwner), fl); } FocusEvent fg = new CausedFocusEvent(lightweightChild, FocusEvent.FOCUS_GAINED, false, currentOwner, cause); if (focusLog.isLoggable(PlatformLogger.Level.FINER)) { focusLog.finer("Posting focus event: " + fg); } SunToolkit.postEvent(SunToolkit.targetToAppContext(lightweightChild), fg); return true; }
Example 7
Source File: XComponentPeer.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
void handleJavaFocusEvent(AWTEvent e) { if (focusLog.isLoggable(PlatformLogger.Level.FINER)) { focusLog.finer(e.toString()); } if (e.getID() == FocusEvent.FOCUS_GAINED) { focusGained((FocusEvent)e); } else { focusLost((FocusEvent)e); } }
Example 8
Source File: ChildFocusWatcher.java From consulo with Apache License 2.0 | 5 votes |
public void eventDispatched(final AWTEvent event) { if (event instanceof FocusEvent) { final FocusEvent fe = (FocusEvent)event; final Component component = fe.getComponent(); if (component == null) return; if (!SwingUtilities.isDescendingFrom(component, myParent)) return; if (fe.getID() == FocusEvent.FOCUS_GAINED) { onFocusGained(fe); } else if (fe.getID() == FocusEvent.FOCUS_LAST) { onFocusLost(fe); } } }
Example 9
Source File: XComponentPeer.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
void handleJavaFocusEvent(AWTEvent e) { if (focusLog.isLoggable(PlatformLogger.Level.FINER)) { focusLog.finer(e.toString()); } if (e.getID() == FocusEvent.FOCUS_GAINED) { focusGained((FocusEvent)e); } else { focusLost((FocusEvent)e); } }
Example 10
Source File: WComponentPeer.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("fallthrough") public void handleEvent(AWTEvent e) { int id = e.getID(); if ((e instanceof InputEvent) && !((InputEvent)e).isConsumed() && ((Component)target).isEnabled()) { if (e instanceof MouseEvent && !(e instanceof MouseWheelEvent)) { handleJavaMouseEvent((MouseEvent) e); } else if (e instanceof KeyEvent) { if (handleJavaKeyEvent((KeyEvent)e)) { return; } } } switch(id) { case PaintEvent.PAINT: // Got native painting paintPending = false; // Fallthrough to next statement case PaintEvent.UPDATE: // Skip all painting while layouting and all UPDATEs // while waiting for native paint if (!isLayouting && ! paintPending) { paintArea.paint(target,shouldClearRectBeforePaint()); } return; case FocusEvent.FOCUS_LOST: case FocusEvent.FOCUS_GAINED: handleJavaFocusEvent((FocusEvent)e); default: break; } // Call the native code nativeHandleEvent(e); }
Example 11
Source File: KeyboardFocusManagerPeerImpl.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("deprecation") public static boolean deliverFocus(Component lightweightChild, Component target, boolean temporary, boolean focusedWindowChangeAllowed, long time, CausedFocusEvent.Cause cause, Component currentFocusOwner) // provided by the descendant peers { if (lightweightChild == null) { lightweightChild = target; } Component currentOwner = currentFocusOwner; if (currentOwner != null && currentOwner.getPeer() == null) { currentOwner = null; } if (currentOwner != null) { FocusEvent fl = new CausedFocusEvent(currentOwner, FocusEvent.FOCUS_LOST, false, lightweightChild, cause); if (focusLog.isLoggable(PlatformLogger.Level.FINER)) { focusLog.finer("Posting focus event: " + fl); } SunToolkit.postEvent(SunToolkit.targetToAppContext(currentOwner), fl); } FocusEvent fg = new CausedFocusEvent(lightweightChild, FocusEvent.FOCUS_GAINED, false, currentOwner, cause); if (focusLog.isLoggable(PlatformLogger.Level.FINER)) { focusLog.finer("Posting focus event: " + fg); } SunToolkit.postEvent(SunToolkit.targetToAppContext(lightweightChild), fg); return true; }
Example 12
Source File: XComponentPeer.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
void handleJavaFocusEvent(AWTEvent e) { if (focusLog.isLoggable(PlatformLogger.Level.FINER)) { focusLog.finer(e.toString()); } if (e.getID() == FocusEvent.FOCUS_GAINED) { focusGained((FocusEvent)e); } else { focusLost((FocusEvent)e); } }
Example 13
Source File: XComponentPeer.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public void handleEvent(java.awt.AWTEvent e) { if ((e instanceof InputEvent) && !((InputEvent)e).isConsumed() && target.isEnabled()) { if (e instanceof MouseEvent) { if (e instanceof MouseWheelEvent) { handleJavaMouseWheelEvent((MouseWheelEvent) e); } else handleJavaMouseEvent((MouseEvent) e); } else if (e instanceof KeyEvent) { handleF10JavaKeyEvent((KeyEvent)e); handleJavaKeyEvent((KeyEvent)e); } } else if (e instanceof KeyEvent && !((InputEvent)e).isConsumed()) { // even if target is disabled. handleF10JavaKeyEvent((KeyEvent)e); } else if (e instanceof InputMethodEvent) { handleJavaInputMethodEvent((InputMethodEvent) e); } int id = e.getID(); switch(id) { case PaintEvent.PAINT: // Got native painting paintPending = false; // Fallthrough to next statement case PaintEvent.UPDATE: // Skip all painting while layouting and all UPDATEs // while waiting for native paint if (!isLayouting && !paintPending) { paintArea.paint(target,false); } return; case FocusEvent.FOCUS_LOST: case FocusEvent.FOCUS_GAINED: handleJavaFocusEvent(e); break; case WindowEvent.WINDOW_LOST_FOCUS: case WindowEvent.WINDOW_GAINED_FOCUS: handleJavaWindowFocusEvent(e); break; default: break; } }
Example 14
Source File: KeyboardFocusManager.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
static AWTEvent retargetFocusEvent(AWTEvent event) { if (clearingCurrentLightweightRequests) { return event; } KeyboardFocusManager manager = getCurrentKeyboardFocusManager(); if (focusLog.isLoggable(PlatformLogger.Level.FINER)) { if (event instanceof FocusEvent || event instanceof WindowEvent) { focusLog.finer(">>> {0}", String.valueOf(event)); } if (focusLog.isLoggable(PlatformLogger.Level.FINER) && event instanceof KeyEvent) { focusLog.finer(" focus owner is {0}", String.valueOf(manager.getGlobalFocusOwner())); focusLog.finer(">>> {0}", String.valueOf(event)); } } synchronized(heavyweightRequests) { /* * This code handles FOCUS_LOST event which is generated by * DefaultKeyboardFocusManager for FOCUS_GAINED. * * This code based on knowledge of DefaultKeyboardFocusManager's * implementation and might be not applicable for another * KeyboardFocusManager. * * Fix for 4472032 */ if (newFocusOwner != null && event.getID() == FocusEvent.FOCUS_LOST) { FocusEvent fe = (FocusEvent)event; if (manager.getGlobalFocusOwner() == fe.getComponent() && fe.getOppositeComponent() == newFocusOwner) { newFocusOwner = null; return event; } } } processCurrentLightweightRequests(); switch (event.getID()) { case FocusEvent.FOCUS_GAINED: { event = retargetFocusGained((FocusEvent)event); break; } case FocusEvent.FOCUS_LOST: { event = retargetFocusLost((FocusEvent)event); break; } default: /* do nothing */ } return event; }
Example 15
Source File: XComponentPeer.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
public void handleEvent(java.awt.AWTEvent e) { if ((e instanceof InputEvent) && !((InputEvent)e).isConsumed() && target.isEnabled()) { if (e instanceof MouseEvent) { if (e instanceof MouseWheelEvent) { handleJavaMouseWheelEvent((MouseWheelEvent) e); } else handleJavaMouseEvent((MouseEvent) e); } else if (e instanceof KeyEvent) { handleF10JavaKeyEvent((KeyEvent)e); handleJavaKeyEvent((KeyEvent)e); } } else if (e instanceof KeyEvent && !((InputEvent)e).isConsumed()) { // even if target is disabled. handleF10JavaKeyEvent((KeyEvent)e); } else if (e instanceof InputMethodEvent) { handleJavaInputMethodEvent((InputMethodEvent) e); } int id = e.getID(); switch(id) { case PaintEvent.PAINT: // Got native painting paintPending = false; // Fallthrough to next statement case PaintEvent.UPDATE: // Skip all painting while layouting and all UPDATEs // while waiting for native paint if (!isLayouting && !paintPending) { paintArea.paint(target,false); } return; case FocusEvent.FOCUS_LOST: case FocusEvent.FOCUS_GAINED: handleJavaFocusEvent(e); break; case WindowEvent.WINDOW_LOST_FOCUS: case WindowEvent.WINDOW_GAINED_FOCUS: handleJavaWindowFocusEvent(e); break; default: break; } }
Example 16
Source File: KeyboardFocusManager.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
static FocusEvent retargetFocusGained(FocusEvent fe) { assert (fe.getID() == FocusEvent.FOCUS_GAINED); Component currentFocusOwner = getCurrentKeyboardFocusManager(). getGlobalFocusOwner(); Component source = fe.getComponent(); Component opposite = fe.getOppositeComponent(); Component nativeSource = getHeavyweight(source); synchronized (heavyweightRequests) { HeavyweightFocusRequest hwFocusRequest = getFirstHWRequest(); if (hwFocusRequest == HeavyweightFocusRequest.CLEAR_GLOBAL_FOCUS_OWNER) { return retargetUnexpectedFocusEvent(fe); } if (source != null && nativeSource == null && hwFocusRequest != null) { // if source w/o peer and // if source is equal to first lightweight // then we should correct source and nativeSource if (source == hwFocusRequest.getFirstLightweightRequest().component) { source = hwFocusRequest.heavyweight; nativeSource = source; // source is heavyweight itself } } if (hwFocusRequest != null && nativeSource == hwFocusRequest.heavyweight) { // Focus change as a result of a known call to requestFocus(), // or known click on a peer focusable heavyweight Component. heavyweightRequests.removeFirst(); LightweightFocusRequest lwFocusRequest = hwFocusRequest.lightweightRequests.removeFirst(); Component newSource = lwFocusRequest.component; if (currentFocusOwner != null) { /* * Since we receive FOCUS_GAINED when current focus * owner is not null, corresponding FOCUS_LOST is supposed * to be lost. And so, we keep new focus owner * to determine synthetic FOCUS_LOST event which will be * generated by KeyboardFocusManager for this FOCUS_GAINED. * * This code based on knowledge of * DefaultKeyboardFocusManager's implementation and might * be not applicable for another KeyboardFocusManager. */ newFocusOwner = newSource; } boolean temporary = (opposite == null || isTemporary(newSource, opposite)) ? false : lwFocusRequest.temporary; if (hwFocusRequest.lightweightRequests.size() > 0) { currentLightweightRequests = hwFocusRequest.lightweightRequests; EventQueue.invokeLater(new Runnable() { public void run() { processCurrentLightweightRequests(); } }); } // 'opposite' will be fixed by // DefaultKeyboardFocusManager.realOppositeComponent return new FocusEvent(newSource, FocusEvent.FOCUS_GAINED, temporary, opposite, lwFocusRequest.cause); } if (currentFocusOwner != null && currentFocusOwner.getContainingWindow() == source && (hwFocusRequest == null || source != hwFocusRequest.heavyweight)) { // Special case for FOCUS_GAINED in top-levels // If it arrives as the result of activation we should skip it // This event will not have appropriate request record and // on arrival there will be already some focus owner set. return new FocusEvent(currentFocusOwner, FocusEvent.FOCUS_GAINED, false, null, FocusEvent.Cause.ACTIVATION); } return retargetUnexpectedFocusEvent(fe); } // end synchronized(heavyweightRequests) }
Example 17
Source File: InputContext.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
/** * @see java.awt.im.InputContext#dispatchEvent */ @SuppressWarnings("fallthrough") public void dispatchEvent(AWTEvent event) { if (event instanceof InputMethodEvent) { return; } // Ignore focus events that relate to the InputMethodWindow of this context. // This is a workaround. Should be removed after 4452384 is fixed. if (event instanceof FocusEvent) { Component opposite = ((FocusEvent)event).getOppositeComponent(); if ((opposite != null) && (getComponentWindow(opposite) instanceof InputMethodWindow) && (opposite.getInputContext() == this)) { return; } } InputMethod inputMethod = getInputMethod(); int id = event.getID(); switch (id) { case FocusEvent.FOCUS_GAINED: focusGained((Component) event.getSource()); break; case FocusEvent.FOCUS_LOST: focusLost((Component) event.getSource(), ((FocusEvent) event).isTemporary()); break; case KeyEvent.KEY_PRESSED: if (checkInputMethodSelectionKey((KeyEvent)event)) { // pop up the input method selection menu InputMethodManager.getInstance().notifyChangeRequestByHotKey((Component)event.getSource()); break; } // fall through default: if ((inputMethod != null) && (event instanceof InputEvent)) { inputMethod.dispatchEvent(event); } } }
Example 18
Source File: InputContext.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
/** * @see java.awt.im.InputContext#dispatchEvent */ @SuppressWarnings("fallthrough") public void dispatchEvent(AWTEvent event) { if (event instanceof InputMethodEvent) { return; } // Ignore focus events that relate to the InputMethodWindow of this context. // This is a workaround. Should be removed after 4452384 is fixed. if (event instanceof FocusEvent) { Component opposite = ((FocusEvent)event).getOppositeComponent(); if ((opposite != null) && (getComponentWindow(opposite) instanceof InputMethodWindow) && (opposite.getInputContext() == this)) { return; } } InputMethod inputMethod = getInputMethod(); int id = event.getID(); switch (id) { case FocusEvent.FOCUS_GAINED: focusGained((Component) event.getSource()); break; case FocusEvent.FOCUS_LOST: focusLost((Component) event.getSource(), ((FocusEvent) event).isTemporary()); break; case KeyEvent.KEY_PRESSED: if (checkInputMethodSelectionKey((KeyEvent)event)) { // pop up the input method selection menu InputMethodManager.getInstance().notifyChangeRequestByHotKey((Component)event.getSource()); break; } // fall through default: if ((inputMethod != null) && (event instanceof InputEvent)) { inputMethod.dispatchEvent(event); } } }
Example 19
Source File: KeyboardFocusManager.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
static AWTEvent retargetFocusEvent(AWTEvent event) { if (clearingCurrentLightweightRequests) { return event; } KeyboardFocusManager manager = getCurrentKeyboardFocusManager(); if (focusLog.isLoggable(PlatformLogger.Level.FINER)) { if (event instanceof FocusEvent || event instanceof WindowEvent) { focusLog.finer(">>> {0}", String.valueOf(event)); } if (focusLog.isLoggable(PlatformLogger.Level.FINER) && event instanceof KeyEvent) { focusLog.finer(" focus owner is {0}", String.valueOf(manager.getGlobalFocusOwner())); focusLog.finer(">>> {0}", String.valueOf(event)); } } synchronized(heavyweightRequests) { /* * This code handles FOCUS_LOST event which is generated by * DefaultKeyboardFocusManager for FOCUS_GAINED. * * This code based on knowledge of DefaultKeyboardFocusManager's * implementation and might be not applicable for another * KeyboardFocusManager. * * Fix for 4472032 */ if (newFocusOwner != null && event.getID() == FocusEvent.FOCUS_LOST) { FocusEvent fe = (FocusEvent)event; if (manager.getGlobalFocusOwner() == fe.getComponent() && fe.getOppositeComponent() == newFocusOwner) { newFocusOwner = null; return event; } } } processCurrentLightweightRequests(); switch (event.getID()) { case FocusEvent.FOCUS_GAINED: { event = retargetFocusGained((FocusEvent)event); break; } case FocusEvent.FOCUS_LOST: { event = retargetFocusLost((FocusEvent)event); break; } default: /* do nothing */ } return event; }
Example 20
Source File: KeyboardFocusManager.java From jdk1.8-source-analysis with Apache License 2.0 | 4 votes |
static FocusEvent retargetFocusGained(FocusEvent fe) { assert (fe.getID() == FocusEvent.FOCUS_GAINED); Component currentFocusOwner = getCurrentKeyboardFocusManager(). getGlobalFocusOwner(); Component source = fe.getComponent(); Component opposite = fe.getOppositeComponent(); Component nativeSource = getHeavyweight(source); synchronized (heavyweightRequests) { HeavyweightFocusRequest hwFocusRequest = getFirstHWRequest(); if (hwFocusRequest == HeavyweightFocusRequest.CLEAR_GLOBAL_FOCUS_OWNER) { return retargetUnexpectedFocusEvent(fe); } if (source != null && nativeSource == null && hwFocusRequest != null) { // if source w/o peer and // if source is equal to first lightweight // then we should correct source and nativeSource if (source == hwFocusRequest.getFirstLightweightRequest().component) { source = hwFocusRequest.heavyweight; nativeSource = source; // source is heavuweight itself } } if (hwFocusRequest != null && nativeSource == hwFocusRequest.heavyweight) { // Focus change as a result of a known call to requestFocus(), // or known click on a peer focusable heavyweight Component. heavyweightRequests.removeFirst(); LightweightFocusRequest lwFocusRequest = hwFocusRequest.lightweightRequests.removeFirst(); Component newSource = lwFocusRequest.component; if (currentFocusOwner != null) { /* * Since we receive FOCUS_GAINED when current focus * owner is not null, correcponding FOCUS_LOST is supposed * to be lost. And so, we keep new focus owner * to determine synthetic FOCUS_LOST event which will be * generated by KeyboardFocusManager for this FOCUS_GAINED. * * This code based on knowledge of * DefaultKeyboardFocusManager's implementation and might * be not applicable for another KeyboardFocusManager. */ newFocusOwner = newSource; } boolean temporary = (opposite == null || isTemporary(newSource, opposite)) ? false : lwFocusRequest.temporary; if (hwFocusRequest.lightweightRequests.size() > 0) { currentLightweightRequests = hwFocusRequest.lightweightRequests; EventQueue.invokeLater(new Runnable() { public void run() { processCurrentLightweightRequests(); } }); } // 'opposite' will be fixed by // DefaultKeyboardFocusManager.realOppositeComponent return new CausedFocusEvent(newSource, FocusEvent.FOCUS_GAINED, temporary, opposite, lwFocusRequest.cause); } if (currentFocusOwner != null && currentFocusOwner.getContainingWindow() == source && (hwFocusRequest == null || source != hwFocusRequest.heavyweight)) { // Special case for FOCUS_GAINED in top-levels // If it arrives as the result of activation we should skip it // This event will not have appropriate request record and // on arrival there will be already some focus owner set. return new CausedFocusEvent(currentFocusOwner, FocusEvent.FOCUS_GAINED, false, null, CausedFocusEvent.Cause.ACTIVATION); } return retargetUnexpectedFocusEvent(fe); } // end synchronized(heavyweightRequests) }