Java Code Examples for sun.awt.CausedFocusEvent#Cause

The following examples show how to use sun.awt.CausedFocusEvent#Cause . 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: KeyboardFocusManager.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
boolean addLightweightRequest(Component descendant,
                              boolean temporary, CausedFocusEvent.Cause cause) {
    if (log.isLoggable(PlatformLogger.Level.FINE)) {
        if (this == HeavyweightFocusRequest.CLEAR_GLOBAL_FOCUS_OWNER) {
            log.fine("Assertion (this != HeavyweightFocusRequest.CLEAR_GLOBAL_FOCUS_OWNER) failed");
        }
        if (descendant == null) {
            log.fine("Assertion (descendant != null) failed");
        }
    }

    Component lastDescendant = ((lightweightRequests.size() > 0)
        ? lightweightRequests.getLast().component
        : null);

    if (descendant != lastDescendant) {
        // Not a duplicate request
        lightweightRequests.add
            (new LightweightFocusRequest(descendant, temporary, cause));
        return true;
    } else {
        return false;
    }
}
 
Example 2
Source File: LWLightweightFramePeer.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
public boolean requestWindowFocus(CausedFocusEvent.Cause cause) {
    if (!focusAllowedFor()) {
        return false;
    }
    if (getPlatformWindow().rejectFocusRequest(cause)) {
        return false;
    }

    Window opposite = LWKeyboardFocusManagerPeer.getInstance().
        getCurrentFocusedWindow();

    changeFocusedWindow(true, opposite);

    return true;
}
 
Example 3
Source File: LWLightweightFramePeer.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public boolean requestWindowFocus(CausedFocusEvent.Cause cause) {
    if (!focusAllowedFor()) {
        return false;
    }
    if (getPlatformWindow().rejectFocusRequest(cause)) {
        return false;
    }

    Window opposite = LWKeyboardFocusManagerPeer.getInstance().
        getCurrentFocusedWindow();

    changeFocusedWindow(true, opposite);

    return true;
}
 
Example 4
Source File: KeyboardFocusManager.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
boolean addLightweightRequest(Component descendant,
                              boolean temporary, CausedFocusEvent.Cause cause) {
    if (log.isLoggable(PlatformLogger.Level.FINE)) {
        if (this == HeavyweightFocusRequest.CLEAR_GLOBAL_FOCUS_OWNER) {
            log.fine("Assertion (this != HeavyweightFocusRequest.CLEAR_GLOBAL_FOCUS_OWNER) failed");
        }
        if (descendant == null) {
            log.fine("Assertion (descendant != null) failed");
        }
    }

    Component lastDescendant = ((lightweightRequests.size() > 0)
        ? lightweightRequests.getLast().component
        : null);

    if (descendant != lastDescendant) {
        // Not a duplicate request
        lightweightRequests.add
            (new LightweightFocusRequest(descendant, temporary, cause));
        return true;
    } else {
        return false;
    }
}
 
Example 5
Source File: XKeyboardFocusManagerPeer.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static boolean deliverFocus(Component lightweightChild,
                                   Component target,
                                   boolean temporary,
                                   boolean focusedWindowChangeAllowed,
                                   long time,
                                   CausedFocusEvent.Cause cause)
{
    return KeyboardFocusManagerPeerImpl.deliverFocus(lightweightChild,
                                                     target,
                                                     temporary,
                                                     focusedWindowChangeAllowed,
                                                     time,
                                                     cause,
                                                     getInstance().getCurrentFocusOwner());
}
 
Example 6
Source File: XKeyboardFocusManagerPeer.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public static boolean deliverFocus(Component lightweightChild,
                                   Component target,
                                   boolean temporary,
                                   boolean focusedWindowChangeAllowed,
                                   long time,
                                   CausedFocusEvent.Cause cause)
{
    return KeyboardFocusManagerPeerImpl.deliverFocus(lightweightChild,
                                                     target,
                                                     temporary,
                                                     focusedWindowChangeAllowed,
                                                     time,
                                                     cause,
                                                     getInstance().getCurrentFocusOwner());
}
 
Example 7
Source File: WFileDialogPeer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean requestFocus
     (Component lightweightChild, boolean temporary,
      boolean focusedWindowChangeAllowed, long time, CausedFocusEvent.Cause cause)
{
    return false;
}
 
Example 8
Source File: KeyboardFocusManager.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public int shouldNativelyFocusHeavyweight(Component heavyweight,
                                   Component descendant,
                                   boolean temporary,
                                   boolean focusedWindowChangeAllowed,
                                   long time,
                                   CausedFocusEvent.Cause cause)
{
    return KeyboardFocusManager.shouldNativelyFocusHeavyweight(
        heavyweight, descendant, temporary, focusedWindowChangeAllowed, time, cause);
}
 
Example 9
Source File: CPlatformEmbeddedFrame.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean rejectFocusRequest(CausedFocusEvent.Cause cause) {
    // Cross-app activation requests are not allowed.
    if (cause != CausedFocusEvent.Cause.MOUSE_EVENT &&
        !target.isParentWindowActive())
    {
        focusLogger.fine("the embedder is inactive, so the request is rejected");
        return true;
    }
    return false;
}
 
Example 10
Source File: WComponentPeer.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override
@SuppressWarnings("deprecation")
public boolean requestFocus(Component lightweightChild, boolean temporary,
                            boolean focusedWindowChangeAllowed, long time,
                            CausedFocusEvent.Cause cause)
{
    if (WKeyboardFocusManagerPeer.
        processSynchronousLightweightTransfer((Component)target, lightweightChild, temporary,
                                              focusedWindowChangeAllowed, time))
    {
        return true;
    }

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

    switch (result) {
      case WKeyboardFocusManagerPeer.SNFH_FAILURE:
          return false;
      case WKeyboardFocusManagerPeer.SNFH_SUCCESS_PROCEED:
          if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
              focusLog.finer("Proceeding with request to " + lightweightChild + " in " + target);
          }
          Window parentWindow = SunToolkit.getContainingWindow((Component)target);
          if (parentWindow == null) {
              return rejectFocusRequestHelper("WARNING: Parent window is null");
          }
          WWindowPeer wpeer = (WWindowPeer)parentWindow.getPeer();
          if (wpeer == null) {
              return rejectFocusRequestHelper("WARNING: Parent window's peer is null");
          }
          boolean res = wpeer.requestWindowFocus(cause);

          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 WKeyboardFocusManagerPeer.deliverFocus(lightweightChild,
                                                        (Component)target,
                                                        temporary,
                                                        focusedWindowChangeAllowed,
                                                        time, cause);

      case WKeyboardFocusManagerPeer.SNFH_SUCCESS_HANDLED:
          // Either lightweight or excessive request - all events are generated.
          return true;
    }
    return false;
}
 
Example 11
Source File: WComponentPeer.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override
@SuppressWarnings("deprecation")
public boolean requestFocus(Component lightweightChild, boolean temporary,
                            boolean focusedWindowChangeAllowed, long time,
                            CausedFocusEvent.Cause cause)
{
    if (WKeyboardFocusManagerPeer.
        processSynchronousLightweightTransfer((Component)target, lightweightChild, temporary,
                                              focusedWindowChangeAllowed, time))
    {
        return true;
    }

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

    switch (result) {
      case WKeyboardFocusManagerPeer.SNFH_FAILURE:
          return false;
      case WKeyboardFocusManagerPeer.SNFH_SUCCESS_PROCEED:
          if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
              focusLog.finer("Proceeding with request to " + lightweightChild + " in " + target);
          }
          Window parentWindow = SunToolkit.getContainingWindow((Component)target);
          if (parentWindow == null) {
              return rejectFocusRequestHelper("WARNING: Parent window is null");
          }
          WWindowPeer wpeer = (WWindowPeer)parentWindow.getPeer();
          if (wpeer == null) {
              return rejectFocusRequestHelper("WARNING: Parent window's peer is null");
          }
          boolean res = wpeer.requestWindowFocus(cause);

          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 WKeyboardFocusManagerPeer.deliverFocus(lightweightChild,
                                                        (Component)target,
                                                        temporary,
                                                        focusedWindowChangeAllowed,
                                                        time, cause);

      case WKeyboardFocusManagerPeer.SNFH_SUCCESS_HANDLED:
          // Either lightweight or excessive request - all events are generated.
          return true;
    }
    return false;
}
 
Example 12
Source File: WComponentPeer.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
public boolean requestFocus(Component lightweightChild, boolean temporary,
                            boolean focusedWindowChangeAllowed, long time,
                            CausedFocusEvent.Cause cause)
{
    if (WKeyboardFocusManagerPeer.
        processSynchronousLightweightTransfer((Component)target, lightweightChild, temporary,
                                              focusedWindowChangeAllowed, time))
    {
        return true;
    }

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

    switch (result) {
      case WKeyboardFocusManagerPeer.SNFH_FAILURE:
          return false;
      case WKeyboardFocusManagerPeer.SNFH_SUCCESS_PROCEED:
          if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
              focusLog.finer("Proceeding with request to " + lightweightChild + " in " + target);
          }
          Window parentWindow = SunToolkit.getContainingWindow((Component)target);
          if (parentWindow == null) {
              return rejectFocusRequestHelper("WARNING: Parent window is null");
          }
          WWindowPeer wpeer = (WWindowPeer)parentWindow.getPeer();
          if (wpeer == null) {
              return rejectFocusRequestHelper("WARNING: Parent window's peer is null");
          }
          boolean res = wpeer.requestWindowFocus(cause);

          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 WKeyboardFocusManagerPeer.deliverFocus(lightweightChild,
                                                        (Component)target,
                                                        temporary,
                                                        focusedWindowChangeAllowed,
                                                        time, cause);

      case WKeyboardFocusManagerPeer.SNFH_SUCCESS_HANDLED:
          // Either lightweight or excessive request - all events are generated.
          return true;
    }
    return false;
}
 
Example 13
Source File: KeyboardFocusManager.java    From jdk-1.7-annotated with Apache License 2.0 4 votes vote down vote up
LightweightFocusRequest(Component component, boolean temporary, CausedFocusEvent.Cause cause) {
    this.component = component;
    this.temporary = temporary;
    this.cause = cause;
}
 
Example 14
Source File: StubPeerCrash.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public boolean             requestFocus(Component lightweightChild,
                                 boolean temporary,
                                 boolean focusedWindowChangeAllowed,
                                 long time, CausedFocusEvent.Cause cause){
    return true;
}
 
Example 15
Source File: KeyboardFocusManager.java    From Java8CN with Apache License 2.0 4 votes vote down vote up
LightweightFocusRequest(Component component, boolean temporary, CausedFocusEvent.Cause cause) {
    this.component = component;
    this.temporary = temporary;
    this.cause = cause;
}
 
Example 16
Source File: ComponentPeer.java    From jdk-1.7-annotated with Apache License 2.0 2 votes vote down vote up
/**
 * Requests focus on this component.
 *
 * @param lightweightChild the actual lightweight child that requests the
 *        focus
 * @param temporary {@code true} if the focus change is temporary,
 *        {@code false} otherwise
 * @param focusedWindowChangeAllowed {@code true} if changing the
 *        focus of the containing window is allowed or not
 * @param time the time of the focus change request
 * @param cause the cause of the focus change request
 *
 * @return {@code true} if the focus change is guaranteed to be
 *         granted, {@code false} otherwise
 */
boolean requestFocus(Component lightweightChild, boolean temporary,
                     boolean focusedWindowChangeAllowed, long time,
                     CausedFocusEvent.Cause cause);
 
Example 17
Source File: ComponentPeer.java    From jdk8u-jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Requests focus on this component.
 *
 * @param lightweightChild the actual lightweight child that requests the
 *        focus
 * @param temporary {@code true} if the focus change is temporary,
 *        {@code false} otherwise
 * @param focusedWindowChangeAllowed {@code true} if changing the
 *        focus of the containing window is allowed or not
 * @param time the time of the focus change request
 * @param cause the cause of the focus change request
 *
 * @return {@code true} if the focus change is guaranteed to be
 *         granted, {@code false} otherwise
 */
boolean requestFocus(Component lightweightChild, boolean temporary,
                     boolean focusedWindowChangeAllowed, long time,
                     CausedFocusEvent.Cause cause);
 
Example 18
Source File: PlatformWindow.java    From openjdk-jdk8u with GNU General Public License v2.0 votes vote down vote up
public boolean rejectFocusRequest(CausedFocusEvent.Cause cause); 
Example 19
Source File: PlatformWindow.java    From jdk8u_jdk with GNU General Public License v2.0 votes vote down vote up
public boolean rejectFocusRequest(CausedFocusEvent.Cause cause); 
Example 20
Source File: PlatformWindow.java    From jdk8u-jdk with GNU General Public License v2.0 votes vote down vote up
public boolean rejectFocusRequest(CausedFocusEvent.Cause cause);