sun.awt.CausedFocusEvent Java Examples

The following examples show how to use sun.awt.CausedFocusEvent. 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: LWLightweightFramePeer.java    From openjdk-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 #2
Source File: DefaultKeyboardFocusManager.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private boolean doRestoreFocus(Component toFocus, Component vetoedComponent,
                               boolean clearOnFailure)
{
    if (toFocus != vetoedComponent && toFocus.isShowing() && toFocus.canBeFocusOwner() &&
        toFocus.requestFocus(false, CausedFocusEvent.Cause.ROLLBACK))
    {
        return true;
    } else {
        Component nextFocus = toFocus.getNextFocusCandidate();
        if (nextFocus != null && nextFocus != vetoedComponent &&
            nextFocus.requestFocusInWindow(CausedFocusEvent.Cause.ROLLBACK))
        {
            return true;
        } else if (clearOnFailure) {
            clearGlobalFocusOwnerPriv();
            return true;
        } else {
            return false;
        }
    }
}
 
Example #3
Source File: DefaultKeyboardFocusManager.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private boolean doRestoreFocus(Component toFocus, Component vetoedComponent,
                               boolean clearOnFailure)
{
    boolean success = true;
    if (toFocus != vetoedComponent && toFocus.isShowing() && toFocus.canBeFocusOwner() &&
        (success = toFocus.requestFocus(false, CausedFocusEvent.Cause.ROLLBACK)))
    {
        return true;
    } else {
        if (!success && getGlobalFocusedWindow() != SunToolkit.getContainingWindow(toFocus)) {
            restoreFocusTo = toFocus;
            return true;
        }
        Component nextFocus = toFocus.getNextFocusCandidate();
        if (nextFocus != null && nextFocus != vetoedComponent &&
            nextFocus.requestFocusInWindow(CausedFocusEvent.Cause.ROLLBACK))
        {
            return true;
        } else if (clearOnFailure) {
            clearGlobalFocusOwnerPriv();
            return true;
        } else {
            return false;
        }
    }
}
 
Example #4
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 #5
Source File: DefaultKeyboardFocusManager.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
private boolean doRestoreFocus(Component toFocus, Component vetoedComponent,
                               boolean clearOnFailure)
{
    boolean success = true;
    if (toFocus != vetoedComponent && toFocus.isShowing() && toFocus.canBeFocusOwner() &&
        (success = toFocus.requestFocus(false, CausedFocusEvent.Cause.ROLLBACK)))
    {
        return true;
    } else {
        if (!success && getGlobalFocusedWindow() != SunToolkit.getContainingWindow(toFocus)) {
            restoreFocusTo = toFocus;
            return true;
        }
        Component nextFocus = toFocus.getNextFocusCandidate();
        if (nextFocus != null && nextFocus != vetoedComponent &&
            nextFocus.requestFocusInWindow(CausedFocusEvent.Cause.ROLLBACK))
        {
            return true;
        } else if (clearOnFailure) {
            clearGlobalFocusOwnerPriv();
            return true;
        } else {
            return false;
        }
    }
}
 
Example #6
Source File: WKeyboardFocusManagerPeer.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static boolean deliverFocus(Component lightweightChild,
                                   Component target,
                                   boolean temporary,
                                   boolean focusedWindowChangeAllowed,
                                   long time,
                                   CausedFocusEvent.Cause cause)
{
    // TODO: do something to eliminate this forwarding
    return KeyboardFocusManagerPeerImpl.deliverFocus(lightweightChild,
                                                     target,
                                                     temporary,
                                                     focusedWindowChangeAllowed,
                                                     time,
                                                     cause,
                                                     getNativeFocusOwner());
}
 
Example #7
Source File: WKeyboardFocusManagerPeer.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static boolean deliverFocus(Component lightweightChild,
                                   Component target,
                                   boolean temporary,
                                   boolean focusedWindowChangeAllowed,
                                   long time,
                                   CausedFocusEvent.Cause cause)
{
    // TODO: do something to eliminate this forwarding
    return KeyboardFocusManagerPeerImpl.deliverFocus(lightweightChild,
                                                     target,
                                                     temporary,
                                                     focusedWindowChangeAllowed,
                                                     time,
                                                     cause,
                                                     getNativeFocusOwner());
}
 
Example #8
Source File: WKeyboardFocusManagerPeer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public static boolean deliverFocus(Component lightweightChild,
                                   Component target,
                                   boolean temporary,
                                   boolean focusedWindowChangeAllowed,
                                   long time,
                                   CausedFocusEvent.Cause cause)
{
    // TODO: do something to eliminate this forwarding
    return KeyboardFocusManagerPeerImpl.deliverFocus(lightweightChild,
                                                     target,
                                                     temporary,
                                                     focusedWindowChangeAllowed,
                                                     time,
                                                     cause,
                                                     getNativeFocusOwner());
}
 
Example #9
Source File: DefaultKeyboardFocusManager.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private boolean doRestoreFocus(Component toFocus, Component vetoedComponent,
                               boolean clearOnFailure)
{
    if (toFocus != vetoedComponent && toFocus.isShowing() && toFocus.canBeFocusOwner() &&
        toFocus.requestFocus(false, CausedFocusEvent.Cause.ROLLBACK))
    {
        return true;
    } else {
        Component nextFocus = toFocus.getNextFocusCandidate();
        if (nextFocus != null && nextFocus != vetoedComponent &&
            nextFocus.requestFocusInWindow(CausedFocusEvent.Cause.ROLLBACK))
        {
            return true;
        } else if (clearOnFailure) {
            clearGlobalFocusOwnerPriv();
            return true;
        } else {
            return false;
        }
    }
}
 
Example #10
Source File: KeyboardFocusManager.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
static FocusEvent retargetUnexpectedFocusEvent(FocusEvent fe) {
    synchronized (heavyweightRequests) {
        // Any other case represents a failure condition which we did
        // not expect. We need to clearFocusRequestList() and patch up
        // the event as best as possible.

        if (removeFirstRequest()) {
            return (FocusEvent)retargetFocusEvent(fe);
        }

        Component source = fe.getComponent();
        Component opposite = fe.getOppositeComponent();
        boolean temporary = false;
        if (fe.getID() == FocusEvent.FOCUS_LOST &&
            (opposite == null || isTemporary(opposite, source)))
        {
            temporary = true;
        }
        return new CausedFocusEvent(source, fe.getID(), temporary, opposite,
                                    CausedFocusEvent.Cause.NATIVE_SYSTEM);
    }
}
 
Example #11
Source File: DefaultKeyboardFocusManager.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
private boolean doRestoreFocus(Component toFocus, Component vetoedComponent,
                               boolean clearOnFailure)
{
    if (toFocus != vetoedComponent && toFocus.isShowing() && toFocus.canBeFocusOwner() &&
        toFocus.requestFocus(false, CausedFocusEvent.Cause.ROLLBACK))
    {
        return true;
    } else {
        Component nextFocus = toFocus.getNextFocusCandidate();
        if (nextFocus != null && nextFocus != vetoedComponent &&
            nextFocus.requestFocusInWindow(CausedFocusEvent.Cause.ROLLBACK))
        {
            return true;
        } else if (clearOnFailure) {
            clearGlobalFocusOwnerPriv();
            return true;
        } else {
            return false;
        }
    }
}
 
Example #12
Source File: LWLightweightFramePeer.java    From openjdk-8-source 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 #13
Source File: DefaultKeyboardFocusManager.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
private boolean doRestoreFocus(Component toFocus, Component vetoedComponent,
                               boolean clearOnFailure)
{
    boolean success = true;
    if (toFocus != vetoedComponent && toFocus.isShowing() && toFocus.canBeFocusOwner() &&
        (success = toFocus.requestFocus(false, CausedFocusEvent.Cause.ROLLBACK)))
    {
        return true;
    } else {
        if (!success && getGlobalFocusedWindow() != SunToolkit.getContainingWindow(toFocus)) {
            restoreFocusTo = toFocus;
            return true;
        }
        Component nextFocus = toFocus.getNextFocusCandidate();
        if (nextFocus != null && nextFocus != vetoedComponent &&
            nextFocus.requestFocusInWindow(CausedFocusEvent.Cause.ROLLBACK))
        {
            return true;
        } else if (clearOnFailure) {
            clearGlobalFocusOwnerPriv();
            return true;
        } else {
            return false;
        }
    }
}
 
Example #14
Source File: DefaultKeyboardFocusManager.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
private boolean doRestoreFocus(Component toFocus, Component vetoedComponent,
                               boolean clearOnFailure)
{
    if (toFocus != vetoedComponent && toFocus.isShowing() && toFocus.canBeFocusOwner() &&
        toFocus.requestFocus(false, CausedFocusEvent.Cause.ROLLBACK))
    {
        return true;
    } else {
        Component nextFocus = toFocus.getNextFocusCandidate();
        if (nextFocus != null && nextFocus != vetoedComponent &&
            nextFocus.requestFocusInWindow(CausedFocusEvent.Cause.ROLLBACK))
        {
            return true;
        } else if (clearOnFailure) {
            clearGlobalFocusOwnerPriv();
            return true;
        } else {
            return false;
        }
    }
}
 
Example #15
Source File: KeyboardFocusManager.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
static FocusEvent retargetUnexpectedFocusEvent(FocusEvent fe) {
    synchronized (heavyweightRequests) {
        // Any other case represents a failure condition which we did
        // not expect. We need to clearFocusRequestList() and patch up
        // the event as best as possible.

        if (removeFirstRequest()) {
            return (FocusEvent)retargetFocusEvent(fe);
        }

        Component source = fe.getComponent();
        Component opposite = fe.getOppositeComponent();
        boolean temporary = false;
        if (fe.getID() == FocusEvent.FOCUS_LOST &&
            (opposite == null || isTemporary(opposite, source)))
        {
            temporary = true;
        }
        return new CausedFocusEvent(source, fe.getID(), temporary, opposite,
                                    CausedFocusEvent.Cause.NATIVE_SYSTEM);
    }
}
 
Example #16
Source File: WKeyboardFocusManagerPeer.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public static boolean deliverFocus(Component lightweightChild,
                                   Component target,
                                   boolean temporary,
                                   boolean focusedWindowChangeAllowed,
                                   long time,
                                   CausedFocusEvent.Cause cause)
{
    // TODO: do something to eliminate this forwarding
    return KeyboardFocusManagerPeerImpl.deliverFocus(lightweightChild,
                                                     target,
                                                     temporary,
                                                     focusedWindowChangeAllowed,
                                                     time,
                                                     cause,
                                                     getNativeFocusOwner());
}
 
Example #17
Source File: KeyboardFocusManager.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
static FocusEvent retargetUnexpectedFocusEvent(FocusEvent fe) {
    synchronized (heavyweightRequests) {
        // Any other case represents a failure condition which we did
        // not expect. We need to clearFocusRequestList() and patch up
        // the event as best as possible.

        if (removeFirstRequest()) {
            return (FocusEvent)retargetFocusEvent(fe);
        }

        Component source = fe.getComponent();
        Component opposite = fe.getOppositeComponent();
        boolean temporary = false;
        if (fe.getID() == FocusEvent.FOCUS_LOST &&
            (opposite == null || isTemporary(opposite, source)))
        {
            temporary = true;
        }
        return new CausedFocusEvent(source, fe.getID(), temporary, opposite,
                                    CausedFocusEvent.Cause.NATIVE_SYSTEM);
    }
}
 
Example #18
Source File: LWLightweightFramePeer.java    From jdk8u60 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 #19
Source File: LWLightweightFramePeer.java    From jdk8u-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 #20
Source File: KeyboardFocusManager.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
static FocusEvent retargetUnexpectedFocusEvent(FocusEvent fe) {
    synchronized (heavyweightRequests) {
        // Any other case represents a failure condition which we did
        // not expect. We need to clearFocusRequestList() and patch up
        // the event as best as possible.

        if (removeFirstRequest()) {
            return (FocusEvent)retargetFocusEvent(fe);
        }

        Component source = fe.getComponent();
        Component opposite = fe.getOppositeComponent();
        boolean temporary = false;
        if (fe.getID() == FocusEvent.FOCUS_LOST &&
            (opposite == null || isTemporary(opposite, source)))
        {
            temporary = true;
        }
        return new CausedFocusEvent(source, fe.getID(), temporary, opposite,
                                    CausedFocusEvent.Cause.NATIVE_SYSTEM);
    }
}
 
Example #21
Source File: DefaultKeyboardFocusManager.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private boolean doRestoreFocus(Component toFocus, Component vetoedComponent,
                               boolean clearOnFailure)
{
    boolean success = true;
    if (toFocus != vetoedComponent && toFocus.isShowing() && toFocus.canBeFocusOwner() &&
        (success = toFocus.requestFocus(false, CausedFocusEvent.Cause.ROLLBACK)))
    {
        return true;
    } else {
        if (!success && getGlobalFocusedWindow() != SunToolkit.getContainingWindow(toFocus)) {
            restoreFocusTo = toFocus;
            return true;
        }
        Component nextFocus = toFocus.getNextFocusCandidate();
        if (nextFocus != null && nextFocus != vetoedComponent &&
            nextFocus.requestFocusInWindow(CausedFocusEvent.Cause.ROLLBACK))
        {
            return true;
        } else if (clearOnFailure) {
            clearGlobalFocusOwnerPriv();
            return true;
        } else {
            return false;
        }
    }
}
 
Example #22
Source File: KeyboardFocusManager.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
HeavyweightFocusRequest(Component heavyweight, Component descendant,
                        boolean temporary, CausedFocusEvent.Cause cause) {
    if (log.isLoggable(PlatformLogger.Level.FINE)) {
        if (heavyweight == null) {
            log.fine("Assertion (heavyweight != null) failed");
        }
    }

    this.heavyweight = heavyweight;
    this.lightweightRequests = new LinkedList<LightweightFocusRequest>();
    addLightweightRequest(descendant, temporary, cause);
}
 
Example #23
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 #24
Source File: CPlatformEmbeddedFrame.java    From TencentKona-8 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 #25
Source File: KeyboardFocusManager.java    From jdk8u-jdk 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 #26
Source File: WFileDialogPeer.java    From TencentKona-8 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 #27
Source File: WComponentPeer.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void handleJavaMouseEvent(MouseEvent e) {
    switch (e.getID()) {
      case MouseEvent.MOUSE_PRESSED:
          // Note that Swing requests focus in its own mouse event handler.
          if (target == e.getSource() &&
              !((Component)target).isFocusOwner() &&
              WKeyboardFocusManagerPeer.shouldFocusOnClick((Component)target))
          {
              WKeyboardFocusManagerPeer.requestFocusFor((Component)target,
                                                        CausedFocusEvent.Cause.MOUSE_EVENT);
          }
          break;
    }
}
 
Example #28
Source File: WComponentPeer.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void handleJavaMouseEvent(MouseEvent e) {
    switch (e.getID()) {
      case MouseEvent.MOUSE_PRESSED:
          // Note that Swing requests focus in its own mouse event handler.
          if (target == e.getSource() &&
              !((Component)target).isFocusOwner() &&
              WKeyboardFocusManagerPeer.shouldFocusOnClick((Component)target))
          {
              WKeyboardFocusManagerPeer.requestFocusFor((Component)target,
                                                        CausedFocusEvent.Cause.MOUSE_EVENT);
          }
          break;
    }
}
 
Example #29
Source File: CPlatformEmbeddedFrame.java    From openjdk-8 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 #30
Source File: DefaultKeyboardFocusManager.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private boolean restoreFocus(Window aWindow, Component vetoedComponent,
                             boolean clearOnFailure) {
    restoreFocusTo = null;
    Component toFocus =
        KeyboardFocusManager.getMostRecentFocusOwner(aWindow);

    if (toFocus != null && toFocus != vetoedComponent) {
        if (getHeavyweight(aWindow) != getNativeFocusOwner()) {
            // cannot restore focus synchronously
            if (!toFocus.isShowing() || !toFocus.canBeFocusOwner()) {
                toFocus = toFocus.getNextFocusCandidate();
            }
            if (toFocus != null && toFocus != vetoedComponent) {
                if (!toFocus.requestFocus(false,
                                               CausedFocusEvent.Cause.ROLLBACK)) {
                    restoreFocusTo = toFocus;
                }
                return true;
            }
        } else if (doRestoreFocus(toFocus, vetoedComponent, false)) {
            return true;
        }
    }
    if (clearOnFailure) {
        clearGlobalFocusOwnerPriv();
        return true;
    } else {
        return false;
    }
}