java.awt.Window#isFocused ( )源码实例Demo

下面列出了java.awt.Window#isFocused ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: dragonwell8_jdk   文件: XComponentPeer.java
final public boolean requestFocus(Component lightweightChild, boolean temporary,
                                  boolean focusedWindowChangeAllowed, long time,
                                  CausedFocusEvent.Cause cause)
{
    if (XKeyboardFocusManagerPeer.
        processSynchronousLightweightTransfer(target, lightweightChild, temporary,
                                              focusedWindowChangeAllowed, time))
    {
        return true;
    }

    int result = XKeyboardFocusManagerPeer.
        shouldNativelyFocusHeavyweight(target, lightweightChild,
                                       temporary, focusedWindowChangeAllowed,
                                       time, cause);

    switch (result) {
      case XKeyboardFocusManagerPeer.SNFH_FAILURE:
          return false;
      case XKeyboardFocusManagerPeer.SNFH_SUCCESS_PROCEED:
          // Currently we just generate focus events like we deal with lightweight instead of calling
          // XSetInputFocus on native window
          if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
              focusLog.finer("Proceeding with request to " +
                             lightweightChild + " in " + target);
          }
          /**
           * The problems with requests in non-focused window arise because shouldNativelyFocusHeavyweight
           * checks that native window is focused while appropriate WINDOW_GAINED_FOCUS has not yet
           * been processed - it is in EventQueue. Thus, SNFH allows native request and stores request record
           * in requests list - and it breaks our requests sequence as first record on WGF should be the last
           * focus owner which had focus before WLF. So, we should not add request record for such requests
           * but store this component in mostRecent - and return true as before for compatibility.
           */
          Window parentWindow = SunToolkit.getContainingWindow(target);
          if (parentWindow == null) {
              return rejectFocusRequestHelper("WARNING: Parent window is null");
          }
          XWindowPeer wpeer = (XWindowPeer)parentWindow.getPeer();
          if (wpeer == null) {
              return rejectFocusRequestHelper("WARNING: Parent window's peer is null");
          }
          /*
           * Passing null 'actualFocusedWindow' as we don't want to restore focus on it
           * when a component inside a Frame is requesting focus.
           * See 6314575 for details.
           */
          boolean res = wpeer.requestWindowFocus(null);

          if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
              focusLog.finer("Requested window focus: " + res);
          }
          // If parent window can be made focused and has been made focused(synchronously)
          // then we can proceed with children, otherwise we retreat.
          if (!(res && parentWindow.isFocused())) {
              return rejectFocusRequestHelper("Waiting for asynchronous processing of the request");
          }
          return XKeyboardFocusManagerPeer.deliverFocus(lightweightChild,
                                                        (Component)target,
                                                        temporary,
                                                        focusedWindowChangeAllowed,
                                                        time, cause);
          // Motif compatibility code
      case XKeyboardFocusManagerPeer.SNFH_SUCCESS_HANDLED:
          // Either lightweight or excessive request - all events are generated.
          return true;
    }
    return false;
}
 
源代码2 项目: TencentKona-8   文件: XComponentPeer.java
final public boolean requestFocus(Component lightweightChild, boolean temporary,
                                  boolean focusedWindowChangeAllowed, long time,
                                  CausedFocusEvent.Cause cause)
{
    if (XKeyboardFocusManagerPeer.
        processSynchronousLightweightTransfer(target, lightweightChild, temporary,
                                              focusedWindowChangeAllowed, time))
    {
        return true;
    }

    int result = XKeyboardFocusManagerPeer.
        shouldNativelyFocusHeavyweight(target, lightweightChild,
                                       temporary, focusedWindowChangeAllowed,
                                       time, cause);

    switch (result) {
      case XKeyboardFocusManagerPeer.SNFH_FAILURE:
          return false;
      case XKeyboardFocusManagerPeer.SNFH_SUCCESS_PROCEED:
          // Currently we just generate focus events like we deal with lightweight instead of calling
          // XSetInputFocus on native window
          if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
              focusLog.finer("Proceeding with request to " +
                             lightweightChild + " in " + target);
          }
          /**
           * The problems with requests in non-focused window arise because shouldNativelyFocusHeavyweight
           * checks that native window is focused while appropriate WINDOW_GAINED_FOCUS has not yet
           * been processed - it is in EventQueue. Thus, SNFH allows native request and stores request record
           * in requests list - and it breaks our requests sequence as first record on WGF should be the last
           * focus owner which had focus before WLF. So, we should not add request record for such requests
           * but store this component in mostRecent - and return true as before for compatibility.
           */
          Window parentWindow = SunToolkit.getContainingWindow(target);
          if (parentWindow == null) {
              return rejectFocusRequestHelper("WARNING: Parent window is null");
          }
          XWindowPeer wpeer = (XWindowPeer)parentWindow.getPeer();
          if (wpeer == null) {
              return rejectFocusRequestHelper("WARNING: Parent window's peer is null");
          }
          /*
           * Passing null 'actualFocusedWindow' as we don't want to restore focus on it
           * when a component inside a Frame is requesting focus.
           * See 6314575 for details.
           */
          boolean res = wpeer.requestWindowFocus(null);

          if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
              focusLog.finer("Requested window focus: " + res);
          }
          // If parent window can be made focused and has been made focused(synchronously)
          // then we can proceed with children, otherwise we retreat.
          if (!(res && parentWindow.isFocused())) {
              return rejectFocusRequestHelper("Waiting for asynchronous processing of the request");
          }
          return XKeyboardFocusManagerPeer.deliverFocus(lightweightChild,
                                                        (Component)target,
                                                        temporary,
                                                        focusedWindowChangeAllowed,
                                                        time, cause);
          // Motif compatibility code
      case XKeyboardFocusManagerPeer.SNFH_SUCCESS_HANDLED:
          // Either lightweight or excessive request - all events are generated.
          return true;
    }
    return false;
}
 
源代码3 项目: jdk8u60   文件: XComponentPeer.java
final public boolean requestFocus(Component lightweightChild, boolean temporary,
                                  boolean focusedWindowChangeAllowed, long time,
                                  CausedFocusEvent.Cause cause)
{
    if (XKeyboardFocusManagerPeer.
        processSynchronousLightweightTransfer(target, lightweightChild, temporary,
                                              focusedWindowChangeAllowed, time))
    {
        return true;
    }

    int result = XKeyboardFocusManagerPeer.
        shouldNativelyFocusHeavyweight(target, lightweightChild,
                                       temporary, focusedWindowChangeAllowed,
                                       time, cause);

    switch (result) {
      case XKeyboardFocusManagerPeer.SNFH_FAILURE:
          return false;
      case XKeyboardFocusManagerPeer.SNFH_SUCCESS_PROCEED:
          // Currently we just generate focus events like we deal with lightweight instead of calling
          // XSetInputFocus on native window
          if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
              focusLog.finer("Proceeding with request to " +
                             lightweightChild + " in " + target);
          }
          /**
           * The problems with requests in non-focused window arise because shouldNativelyFocusHeavyweight
           * checks that native window is focused while appropriate WINDOW_GAINED_FOCUS has not yet
           * been processed - it is in EventQueue. Thus, SNFH allows native request and stores request record
           * in requests list - and it breaks our requests sequence as first record on WGF should be the last
           * focus owner which had focus before WLF. So, we should not add request record for such requests
           * but store this component in mostRecent - and return true as before for compatibility.
           */
          Window parentWindow = SunToolkit.getContainingWindow(target);
          if (parentWindow == null) {
              return rejectFocusRequestHelper("WARNING: Parent window is null");
          }
          XWindowPeer wpeer = (XWindowPeer)parentWindow.getPeer();
          if (wpeer == null) {
              return rejectFocusRequestHelper("WARNING: Parent window's peer is null");
          }
          /*
           * Passing null 'actualFocusedWindow' as we don't want to restore focus on it
           * when a component inside a Frame is requesting focus.
           * See 6314575 for details.
           */
          boolean res = wpeer.requestWindowFocus(null);

          if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
              focusLog.finer("Requested window focus: " + res);
          }
          // If parent window can be made focused and has been made focused(synchronously)
          // then we can proceed with children, otherwise we retreat.
          if (!(res && parentWindow.isFocused())) {
              return rejectFocusRequestHelper("Waiting for asynchronous processing of the request");
          }
          return XKeyboardFocusManagerPeer.deliverFocus(lightweightChild,
                                                        (Component)target,
                                                        temporary,
                                                        focusedWindowChangeAllowed,
                                                        time, cause);
          // Motif compatibility code
      case XKeyboardFocusManagerPeer.SNFH_SUCCESS_HANDLED:
          // Either lightweight or excessive request - all events are generated.
          return true;
    }
    return false;
}
 
源代码4 项目: openjdk-jdk8u   文件: XComponentPeer.java
final public boolean requestFocus(Component lightweightChild, boolean temporary,
                                  boolean focusedWindowChangeAllowed, long time,
                                  CausedFocusEvent.Cause cause)
{
    if (XKeyboardFocusManagerPeer.
        processSynchronousLightweightTransfer(target, lightweightChild, temporary,
                                              focusedWindowChangeAllowed, time))
    {
        return true;
    }

    int result = XKeyboardFocusManagerPeer.
        shouldNativelyFocusHeavyweight(target, lightweightChild,
                                       temporary, focusedWindowChangeAllowed,
                                       time, cause);

    switch (result) {
      case XKeyboardFocusManagerPeer.SNFH_FAILURE:
          return false;
      case XKeyboardFocusManagerPeer.SNFH_SUCCESS_PROCEED:
          // Currently we just generate focus events like we deal with lightweight instead of calling
          // XSetInputFocus on native window
          if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
              focusLog.finer("Proceeding with request to " +
                             lightweightChild + " in " + target);
          }
          /**
           * The problems with requests in non-focused window arise because shouldNativelyFocusHeavyweight
           * checks that native window is focused while appropriate WINDOW_GAINED_FOCUS has not yet
           * been processed - it is in EventQueue. Thus, SNFH allows native request and stores request record
           * in requests list - and it breaks our requests sequence as first record on WGF should be the last
           * focus owner which had focus before WLF. So, we should not add request record for such requests
           * but store this component in mostRecent - and return true as before for compatibility.
           */
          Window parentWindow = SunToolkit.getContainingWindow(target);
          if (parentWindow == null) {
              return rejectFocusRequestHelper("WARNING: Parent window is null");
          }
          XWindowPeer wpeer = (XWindowPeer)parentWindow.getPeer();
          if (wpeer == null) {
              return rejectFocusRequestHelper("WARNING: Parent window's peer is null");
          }
          /*
           * Passing null 'actualFocusedWindow' as we don't want to restore focus on it
           * when a component inside a Frame is requesting focus.
           * See 6314575 for details.
           */
          boolean res = wpeer.requestWindowFocus(null);

          if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
              focusLog.finer("Requested window focus: " + res);
          }
          // If parent window can be made focused and has been made focused(synchronously)
          // then we can proceed with children, otherwise we retreat.
          if (!(res && parentWindow.isFocused())) {
              return rejectFocusRequestHelper("Waiting for asynchronous processing of the request");
          }
          return XKeyboardFocusManagerPeer.deliverFocus(lightweightChild,
                                                        (Component)target,
                                                        temporary,
                                                        focusedWindowChangeAllowed,
                                                        time, cause);
          // Motif compatibility code
      case XKeyboardFocusManagerPeer.SNFH_SUCCESS_HANDLED:
          // Either lightweight or excessive request - all events are generated.
          return true;
    }
    return false;
}
 
源代码5 项目: netbeans   文件: ProfilerTableHovers.java
private static boolean isInFocusedWindow(Component c) {
    Window w = SwingUtilities.getWindowAncestor(c);
    return w != null && w.isFocused();
}
 
源代码6 项目: openjdk-jdk8u-backup   文件: XComponentPeer.java
final public boolean requestFocus(Component lightweightChild, boolean temporary,
                                  boolean focusedWindowChangeAllowed, long time,
                                  CausedFocusEvent.Cause cause)
{
    if (XKeyboardFocusManagerPeer.
        processSynchronousLightweightTransfer(target, lightweightChild, temporary,
                                              focusedWindowChangeAllowed, time))
    {
        return true;
    }

    int result = XKeyboardFocusManagerPeer.
        shouldNativelyFocusHeavyweight(target, lightweightChild,
                                       temporary, focusedWindowChangeAllowed,
                                       time, cause);

    switch (result) {
      case XKeyboardFocusManagerPeer.SNFH_FAILURE:
          return false;
      case XKeyboardFocusManagerPeer.SNFH_SUCCESS_PROCEED:
          // Currently we just generate focus events like we deal with lightweight instead of calling
          // XSetInputFocus on native window
          if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
              focusLog.finer("Proceeding with request to " +
                             lightweightChild + " in " + target);
          }
          /**
           * The problems with requests in non-focused window arise because shouldNativelyFocusHeavyweight
           * checks that native window is focused while appropriate WINDOW_GAINED_FOCUS has not yet
           * been processed - it is in EventQueue. Thus, SNFH allows native request and stores request record
           * in requests list - and it breaks our requests sequence as first record on WGF should be the last
           * focus owner which had focus before WLF. So, we should not add request record for such requests
           * but store this component in mostRecent - and return true as before for compatibility.
           */
          Window parentWindow = SunToolkit.getContainingWindow(target);
          if (parentWindow == null) {
              return rejectFocusRequestHelper("WARNING: Parent window is null");
          }
          XWindowPeer wpeer = (XWindowPeer)parentWindow.getPeer();
          if (wpeer == null) {
              return rejectFocusRequestHelper("WARNING: Parent window's peer is null");
          }
          /*
           * Passing null 'actualFocusedWindow' as we don't want to restore focus on it
           * when a component inside a Frame is requesting focus.
           * See 6314575 for details.
           */
          boolean res = wpeer.requestWindowFocus(null);

          if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
              focusLog.finer("Requested window focus: " + res);
          }
          // If parent window can be made focused and has been made focused(synchronously)
          // then we can proceed with children, otherwise we retreat.
          if (!(res && parentWindow.isFocused())) {
              return rejectFocusRequestHelper("Waiting for asynchronous processing of the request");
          }
          return XKeyboardFocusManagerPeer.deliverFocus(lightweightChild,
                                                        (Component)target,
                                                        temporary,
                                                        focusedWindowChangeAllowed,
                                                        time, cause);
          // Motif compatibility code
      case XKeyboardFocusManagerPeer.SNFH_SUCCESS_HANDLED:
          // Either lightweight or excessive request - all events are generated.
          return true;
    }
    return false;
}
 
源代码7 项目: openjdk-jdk9   文件: XComponentPeer.java
@SuppressWarnings("deprecation")
public final boolean requestFocus(Component lightweightChild, boolean temporary,
                                  boolean focusedWindowChangeAllowed, long time,
                                  FocusEvent.Cause cause)
{
    if (XKeyboardFocusManagerPeer.
        processSynchronousLightweightTransfer(target, lightweightChild, temporary,
                                              focusedWindowChangeAllowed, time))
    {
        return true;
    }

    int result = XKeyboardFocusManagerPeer.
        shouldNativelyFocusHeavyweight(target, lightweightChild,
                                       temporary, focusedWindowChangeAllowed,
                                       time, cause);

    switch (result) {
      case XKeyboardFocusManagerPeer.SNFH_FAILURE:
          return false;
      case XKeyboardFocusManagerPeer.SNFH_SUCCESS_PROCEED:
          // Currently we just generate focus events like we deal with lightweight instead of calling
          // XSetInputFocus on native window
          if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
              focusLog.finer("Proceeding with request to " +
                             lightweightChild + " in " + target);
          }
          /**
           * The problems with requests in non-focused window arise because shouldNativelyFocusHeavyweight
           * checks that native window is focused while appropriate WINDOW_GAINED_FOCUS has not yet
           * been processed - it is in EventQueue. Thus, SNFH allows native request and stores request record
           * in requests list - and it breaks our requests sequence as first record on WGF should be the last
           * focus owner which had focus before WLF. So, we should not add request record for such requests
           * but store this component in mostRecent - and return true as before for compatibility.
           */
          Window parentWindow = SunToolkit.getContainingWindow(target);
          if (parentWindow == null) {
              return rejectFocusRequestHelper("WARNING: Parent window is null");
          }
          XWindowPeer wpeer = AWTAccessor.getComponentAccessor()
                                         .getPeer(parentWindow);
          if (wpeer == null) {
              return rejectFocusRequestHelper("WARNING: Parent window's peer is null");
          }
          /*
           * Passing null 'actualFocusedWindow' as we don't want to restore focus on it
           * when a component inside a Frame is requesting focus.
           * See 6314575 for details.
           */
          boolean res = wpeer.requestWindowFocus(null);

          if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
              focusLog.finer("Requested window focus: " + res);
          }
          // If parent window can be made focused and has been made focused(synchronously)
          // then we can proceed with children, otherwise we retreat.
          if (!(res && parentWindow.isFocused())) {
              return rejectFocusRequestHelper("Waiting for asynchronous processing of the request");
          }
          return XKeyboardFocusManagerPeer.deliverFocus(lightweightChild,
                                                        target,
                                                        temporary,
                                                        focusedWindowChangeAllowed,
                                                        time, cause);
          // Motif compatibility code
      case XKeyboardFocusManagerPeer.SNFH_SUCCESS_HANDLED:
          // Either lightweight or excessive request - all events are generated.
          return true;
    }
    return false;
}
 
源代码8 项目: jdk8u-jdk   文件: XComponentPeer.java
final public boolean requestFocus(Component lightweightChild, boolean temporary,
                                  boolean focusedWindowChangeAllowed, long time,
                                  CausedFocusEvent.Cause cause)
{
    if (XKeyboardFocusManagerPeer.
        processSynchronousLightweightTransfer(target, lightweightChild, temporary,
                                              focusedWindowChangeAllowed, time))
    {
        return true;
    }

    int result = XKeyboardFocusManagerPeer.
        shouldNativelyFocusHeavyweight(target, lightweightChild,
                                       temporary, focusedWindowChangeAllowed,
                                       time, cause);

    switch (result) {
      case XKeyboardFocusManagerPeer.SNFH_FAILURE:
          return false;
      case XKeyboardFocusManagerPeer.SNFH_SUCCESS_PROCEED:
          // Currently we just generate focus events like we deal with lightweight instead of calling
          // XSetInputFocus on native window
          if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
              focusLog.finer("Proceeding with request to " +
                             lightweightChild + " in " + target);
          }
          /**
           * The problems with requests in non-focused window arise because shouldNativelyFocusHeavyweight
           * checks that native window is focused while appropriate WINDOW_GAINED_FOCUS has not yet
           * been processed - it is in EventQueue. Thus, SNFH allows native request and stores request record
           * in requests list - and it breaks our requests sequence as first record on WGF should be the last
           * focus owner which had focus before WLF. So, we should not add request record for such requests
           * but store this component in mostRecent - and return true as before for compatibility.
           */
          Window parentWindow = SunToolkit.getContainingWindow(target);
          if (parentWindow == null) {
              return rejectFocusRequestHelper("WARNING: Parent window is null");
          }
          XWindowPeer wpeer = (XWindowPeer)parentWindow.getPeer();
          if (wpeer == null) {
              return rejectFocusRequestHelper("WARNING: Parent window's peer is null");
          }
          /*
           * Passing null 'actualFocusedWindow' as we don't want to restore focus on it
           * when a component inside a Frame is requesting focus.
           * See 6314575 for details.
           */
          boolean res = wpeer.requestWindowFocus(null);

          if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
              focusLog.finer("Requested window focus: " + res);
          }
          // If parent window can be made focused and has been made focused(synchronously)
          // then we can proceed with children, otherwise we retreat.
          if (!(res && parentWindow.isFocused())) {
              return rejectFocusRequestHelper("Waiting for asynchronous processing of the request");
          }
          return XKeyboardFocusManagerPeer.deliverFocus(lightweightChild,
                                                        (Component)target,
                                                        temporary,
                                                        focusedWindowChangeAllowed,
                                                        time, cause);
          // Motif compatibility code
      case XKeyboardFocusManagerPeer.SNFH_SUCCESS_HANDLED:
          // Either lightweight or excessive request - all events are generated.
          return true;
    }
    return false;
}
 
源代码9 项目: hottub   文件: XComponentPeer.java
final public boolean requestFocus(Component lightweightChild, boolean temporary,
                                  boolean focusedWindowChangeAllowed, long time,
                                  CausedFocusEvent.Cause cause)
{
    if (XKeyboardFocusManagerPeer.
        processSynchronousLightweightTransfer(target, lightweightChild, temporary,
                                              focusedWindowChangeAllowed, time))
    {
        return true;
    }

    int result = XKeyboardFocusManagerPeer.
        shouldNativelyFocusHeavyweight(target, lightweightChild,
                                       temporary, focusedWindowChangeAllowed,
                                       time, cause);

    switch (result) {
      case XKeyboardFocusManagerPeer.SNFH_FAILURE:
          return false;
      case XKeyboardFocusManagerPeer.SNFH_SUCCESS_PROCEED:
          // Currently we just generate focus events like we deal with lightweight instead of calling
          // XSetInputFocus on native window
          if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
              focusLog.finer("Proceeding with request to " +
                             lightweightChild + " in " + target);
          }
          /**
           * The problems with requests in non-focused window arise because shouldNativelyFocusHeavyweight
           * checks that native window is focused while appropriate WINDOW_GAINED_FOCUS has not yet
           * been processed - it is in EventQueue. Thus, SNFH allows native request and stores request record
           * in requests list - and it breaks our requests sequence as first record on WGF should be the last
           * focus owner which had focus before WLF. So, we should not add request record for such requests
           * but store this component in mostRecent - and return true as before for compatibility.
           */
          Window parentWindow = SunToolkit.getContainingWindow(target);
          if (parentWindow == null) {
              return rejectFocusRequestHelper("WARNING: Parent window is null");
          }
          XWindowPeer wpeer = (XWindowPeer)parentWindow.getPeer();
          if (wpeer == null) {
              return rejectFocusRequestHelper("WARNING: Parent window's peer is null");
          }
          /*
           * Passing null 'actualFocusedWindow' as we don't want to restore focus on it
           * when a component inside a Frame is requesting focus.
           * See 6314575 for details.
           */
          boolean res = wpeer.requestWindowFocus(null);

          if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
              focusLog.finer("Requested window focus: " + res);
          }
          // If parent window can be made focused and has been made focused(synchronously)
          // then we can proceed with children, otherwise we retreat.
          if (!(res && parentWindow.isFocused())) {
              return rejectFocusRequestHelper("Waiting for asynchronous processing of the request");
          }
          return XKeyboardFocusManagerPeer.deliverFocus(lightweightChild,
                                                        (Component)target,
                                                        temporary,
                                                        focusedWindowChangeAllowed,
                                                        time, cause);
          // Motif compatibility code
      case XKeyboardFocusManagerPeer.SNFH_SUCCESS_HANDLED:
          // Either lightweight or excessive request - all events are generated.
          return true;
    }
    return false;
}
 
源代码10 项目: openjdk-8-source   文件: XComponentPeer.java
final public boolean requestFocus(Component lightweightChild, boolean temporary,
                                  boolean focusedWindowChangeAllowed, long time,
                                  CausedFocusEvent.Cause cause)
{
    if (XKeyboardFocusManagerPeer.
        processSynchronousLightweightTransfer(target, lightweightChild, temporary,
                                              focusedWindowChangeAllowed, time))
    {
        return true;
    }

    int result = XKeyboardFocusManagerPeer.
        shouldNativelyFocusHeavyweight(target, lightweightChild,
                                       temporary, focusedWindowChangeAllowed,
                                       time, cause);

    switch (result) {
      case XKeyboardFocusManagerPeer.SNFH_FAILURE:
          return false;
      case XKeyboardFocusManagerPeer.SNFH_SUCCESS_PROCEED:
          // Currently we just generate focus events like we deal with lightweight instead of calling
          // XSetInputFocus on native window
          if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
              focusLog.finer("Proceeding with request to " +
                             lightweightChild + " in " + target);
          }
          /**
           * The problems with requests in non-focused window arise because shouldNativelyFocusHeavyweight
           * checks that native window is focused while appropriate WINDOW_GAINED_FOCUS has not yet
           * been processed - it is in EventQueue. Thus, SNFH allows native request and stores request record
           * in requests list - and it breaks our requests sequence as first record on WGF should be the last
           * focus owner which had focus before WLF. So, we should not add request record for such requests
           * but store this component in mostRecent - and return true as before for compatibility.
           */
          Window parentWindow = SunToolkit.getContainingWindow(target);
          if (parentWindow == null) {
              return rejectFocusRequestHelper("WARNING: Parent window is null");
          }
          XWindowPeer wpeer = (XWindowPeer)parentWindow.getPeer();
          if (wpeer == null) {
              return rejectFocusRequestHelper("WARNING: Parent window's peer is null");
          }
          /*
           * Passing null 'actualFocusedWindow' as we don't want to restore focus on it
           * when a component inside a Frame is requesting focus.
           * See 6314575 for details.
           */
          boolean res = wpeer.requestWindowFocus(null);

          if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
              focusLog.finer("Requested window focus: " + res);
          }
          // If parent window can be made focused and has been made focused(synchronously)
          // then we can proceed with children, otherwise we retreat.
          if (!(res && parentWindow.isFocused())) {
              return rejectFocusRequestHelper("Waiting for asynchronous processing of the request");
          }
          return XKeyboardFocusManagerPeer.deliverFocus(lightweightChild,
                                                        (Component)target,
                                                        temporary,
                                                        focusedWindowChangeAllowed,
                                                        time, cause);
          // Motif compatibility code
      case XKeyboardFocusManagerPeer.SNFH_SUCCESS_HANDLED:
          // Either lightweight or excessive request - all events are generated.
          return true;
    }
    return false;
}
 
源代码11 项目: visualvm   文件: ProfilerTableHovers.java
private static boolean isInFocusedWindow(Component c) {
    Window w = SwingUtilities.getWindowAncestor(c);
    return w != null && w.isFocused();
}
 
源代码12 项目: openjdk-8   文件: XComponentPeer.java
final public boolean requestFocus(Component lightweightChild, boolean temporary,
                                  boolean focusedWindowChangeAllowed, long time,
                                  CausedFocusEvent.Cause cause)
{
    if (XKeyboardFocusManagerPeer.
        processSynchronousLightweightTransfer(target, lightweightChild, temporary,
                                              focusedWindowChangeAllowed, time))
    {
        return true;
    }

    int result = XKeyboardFocusManagerPeer.
        shouldNativelyFocusHeavyweight(target, lightweightChild,
                                       temporary, focusedWindowChangeAllowed,
                                       time, cause);

    switch (result) {
      case XKeyboardFocusManagerPeer.SNFH_FAILURE:
          return false;
      case XKeyboardFocusManagerPeer.SNFH_SUCCESS_PROCEED:
          // Currently we just generate focus events like we deal with lightweight instead of calling
          // XSetInputFocus on native window
          if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
              focusLog.finer("Proceeding with request to " +
                             lightweightChild + " in " + target);
          }
          /**
           * The problems with requests in non-focused window arise because shouldNativelyFocusHeavyweight
           * checks that native window is focused while appropriate WINDOW_GAINED_FOCUS has not yet
           * been processed - it is in EventQueue. Thus, SNFH allows native request and stores request record
           * in requests list - and it breaks our requests sequence as first record on WGF should be the last
           * focus owner which had focus before WLF. So, we should not add request record for such requests
           * but store this component in mostRecent - and return true as before for compatibility.
           */
          Window parentWindow = SunToolkit.getContainingWindow(target);
          if (parentWindow == null) {
              return rejectFocusRequestHelper("WARNING: Parent window is null");
          }
          XWindowPeer wpeer = (XWindowPeer)parentWindow.getPeer();
          if (wpeer == null) {
              return rejectFocusRequestHelper("WARNING: Parent window's peer is null");
          }
          /*
           * Passing null 'actualFocusedWindow' as we don't want to restore focus on it
           * when a component inside a Frame is requesting focus.
           * See 6314575 for details.
           */
          boolean res = wpeer.requestWindowFocus(null);

          if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
              focusLog.finer("Requested window focus: " + res);
          }
          // If parent window can be made focused and has been made focused(synchronously)
          // then we can proceed with children, otherwise we retreat.
          if (!(res && parentWindow.isFocused())) {
              return rejectFocusRequestHelper("Waiting for asynchronous processing of the request");
          }
          return XKeyboardFocusManagerPeer.deliverFocus(lightweightChild,
                                                        (Component)target,
                                                        temporary,
                                                        focusedWindowChangeAllowed,
                                                        time, cause);
          // Motif compatibility code
      case XKeyboardFocusManagerPeer.SNFH_SUCCESS_HANDLED:
          // Either lightweight or excessive request - all events are generated.
          return true;
    }
    return false;
}
 
源代码13 项目: jdk8u-jdk   文件: XComponentPeer.java
final public boolean requestFocus(Component lightweightChild, boolean temporary,
                                  boolean focusedWindowChangeAllowed, long time,
                                  CausedFocusEvent.Cause cause)
{
    if (XKeyboardFocusManagerPeer.
        processSynchronousLightweightTransfer(target, lightweightChild, temporary,
                                              focusedWindowChangeAllowed, time))
    {
        return true;
    }

    int result = XKeyboardFocusManagerPeer.
        shouldNativelyFocusHeavyweight(target, lightweightChild,
                                       temporary, focusedWindowChangeAllowed,
                                       time, cause);

    switch (result) {
      case XKeyboardFocusManagerPeer.SNFH_FAILURE:
          return false;
      case XKeyboardFocusManagerPeer.SNFH_SUCCESS_PROCEED:
          // Currently we just generate focus events like we deal with lightweight instead of calling
          // XSetInputFocus on native window
          if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
              focusLog.finer("Proceeding with request to " +
                             lightweightChild + " in " + target);
          }
          /**
           * The problems with requests in non-focused window arise because shouldNativelyFocusHeavyweight
           * checks that native window is focused while appropriate WINDOW_GAINED_FOCUS has not yet
           * been processed - it is in EventQueue. Thus, SNFH allows native request and stores request record
           * in requests list - and it breaks our requests sequence as first record on WGF should be the last
           * focus owner which had focus before WLF. So, we should not add request record for such requests
           * but store this component in mostRecent - and return true as before for compatibility.
           */
          Window parentWindow = SunToolkit.getContainingWindow(target);
          if (parentWindow == null) {
              return rejectFocusRequestHelper("WARNING: Parent window is null");
          }
          XWindowPeer wpeer = (XWindowPeer)parentWindow.getPeer();
          if (wpeer == null) {
              return rejectFocusRequestHelper("WARNING: Parent window's peer is null");
          }
          /*
           * Passing null 'actualFocusedWindow' as we don't want to restore focus on it
           * when a component inside a Frame is requesting focus.
           * See 6314575 for details.
           */
          boolean res = wpeer.requestWindowFocus(null);

          if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
              focusLog.finer("Requested window focus: " + res);
          }
          // If parent window can be made focused and has been made focused(synchronously)
          // then we can proceed with children, otherwise we retreat.
          if (!(res && parentWindow.isFocused())) {
              return rejectFocusRequestHelper("Waiting for asynchronous processing of the request");
          }
          return XKeyboardFocusManagerPeer.deliverFocus(lightweightChild,
                                                        (Component)target,
                                                        temporary,
                                                        focusedWindowChangeAllowed,
                                                        time, cause);
          // Motif compatibility code
      case XKeyboardFocusManagerPeer.SNFH_SUCCESS_HANDLED:
          // Either lightweight or excessive request - all events are generated.
          return true;
    }
    return false;
}
 
源代码14 项目: jdk8u-dev-jdk   文件: XComponentPeer.java
final public boolean requestFocus(Component lightweightChild, boolean temporary,
                                  boolean focusedWindowChangeAllowed, long time,
                                  CausedFocusEvent.Cause cause)
{
    if (XKeyboardFocusManagerPeer.
        processSynchronousLightweightTransfer(target, lightweightChild, temporary,
                                              focusedWindowChangeAllowed, time))
    {
        return true;
    }

    int result = XKeyboardFocusManagerPeer.
        shouldNativelyFocusHeavyweight(target, lightweightChild,
                                       temporary, focusedWindowChangeAllowed,
                                       time, cause);

    switch (result) {
      case XKeyboardFocusManagerPeer.SNFH_FAILURE:
          return false;
      case XKeyboardFocusManagerPeer.SNFH_SUCCESS_PROCEED:
          // Currently we just generate focus events like we deal with lightweight instead of calling
          // XSetInputFocus on native window
          if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
              focusLog.finer("Proceeding with request to " +
                             lightweightChild + " in " + target);
          }
          /**
           * The problems with requests in non-focused window arise because shouldNativelyFocusHeavyweight
           * checks that native window is focused while appropriate WINDOW_GAINED_FOCUS has not yet
           * been processed - it is in EventQueue. Thus, SNFH allows native request and stores request record
           * in requests list - and it breaks our requests sequence as first record on WGF should be the last
           * focus owner which had focus before WLF. So, we should not add request record for such requests
           * but store this component in mostRecent - and return true as before for compatibility.
           */
          Window parentWindow = SunToolkit.getContainingWindow(target);
          if (parentWindow == null) {
              return rejectFocusRequestHelper("WARNING: Parent window is null");
          }
          XWindowPeer wpeer = (XWindowPeer)parentWindow.getPeer();
          if (wpeer == null) {
              return rejectFocusRequestHelper("WARNING: Parent window's peer is null");
          }
          /*
           * Passing null 'actualFocusedWindow' as we don't want to restore focus on it
           * when a component inside a Frame is requesting focus.
           * See 6314575 for details.
           */
          boolean res = wpeer.requestWindowFocus(null);

          if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
              focusLog.finer("Requested window focus: " + res);
          }
          // If parent window can be made focused and has been made focused(synchronously)
          // then we can proceed with children, otherwise we retreat.
          if (!(res && parentWindow.isFocused())) {
              return rejectFocusRequestHelper("Waiting for asynchronous processing of the request");
          }
          return XKeyboardFocusManagerPeer.deliverFocus(lightweightChild,
                                                        (Component)target,
                                                        temporary,
                                                        focusedWindowChangeAllowed,
                                                        time, cause);
          // Motif compatibility code
      case XKeyboardFocusManagerPeer.SNFH_SUCCESS_HANDLED:
          // Either lightweight or excessive request - all events are generated.
          return true;
    }
    return false;
}
 
源代码15 项目: pumpernickel   文件: EmphasizedLabelUI.java
/**
 * {@code true} if the given {@link Component}'s has a parent {@link Window}
 * (i.e. it's not null) and that {@link Window} is currently active
 * (focused).
 *
 * @param component
 *            the {@code Component} to check the parent {@code Window}'s
 *            focus for.
 * @return {@code true} if the given {@code Component}'s parent
 *         {@code Window} is currently active.
 */
public static boolean isParentWindowFocused(Component component) {
	Window window = SwingUtilities.getWindowAncestor(component);
	return window != null && window.isFocused();
}
 
源代码16 项目: seaglass   文件: WindowUtils.java
/**
 * {@code true} if the given {@link Component}'s parent {@link Window} is
 * currently active (focused).
 *
 * @param  component the {@code Component} to check the parent
 *                   {@code Window}'s focus for.
 *
 * @return {@code true} if the given {@code Component}'s parent
 *         {@code Window} is currently active.
 */
public static boolean isParentWindowFocused(Component component) {
    Window window = SwingUtilities.getWindowAncestor(component);

    return window != null && window.isFocused();
}