类sun.awt.CausedFocusEvent源码实例Demo

下面列出了怎么用sun.awt.CausedFocusEvent的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: jdk8u-jdk   文件: LWLightweightFramePeer.java
@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;
}
 
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;
        }
    }
}
 
源代码3 项目: dragonwell8_jdk   文件: KeyboardFocusManager.java
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);
    }
}
 
源代码4 项目: jdk8u-jdk   文件: WKeyboardFocusManagerPeer.java
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());
}
 
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;
        }
    }
}
 
源代码6 项目: openjdk-8   文件: DefaultKeyboardFocusManager.java
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;
        }
    }
}
 
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());
}
 
源代码8 项目: jdk8u-jdk   文件: KeyboardFocusManager.java
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);
    }
}
 
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);
    }
}
 
源代码10 项目: openjdk-8-source   文件: LWLightweightFramePeer.java
@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;
}
 
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());
}
 
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;
        }
    }
}
 
源代码13 项目: TencentKona-8   文件: LWLightweightFramePeer.java
@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;
}
 
源代码14 项目: jdk8u-jdk   文件: DefaultKeyboardFocusManager.java
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;
        }
    }
}
 
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;
        }
    }
}
 
源代码16 项目: openjdk-8   文件: LWLightweightFramePeer.java
@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;
}
 
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;
        }
    }
}
 
源代码18 项目: openjdk-jdk8u   文件: WKeyboardFocusManagerPeer.java
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());
}
 
源代码19 项目: openjdk-8-source   文件: KeyboardFocusManager.java
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);
    }
}
 
源代码20 项目: jdk8u60   文件: LWLightweightFramePeer.java
@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;
}
 
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;
        }
    }
}
 
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);
}
 
源代码23 项目: jdk8u-jdk   文件: WFileDialogPeer.java
@Override
public boolean requestFocus
     (Component lightweightChild, boolean temporary,
      boolean focusedWindowChangeAllowed, long time, CausedFocusEvent.Cause cause)
{
    return false;
}
 
源代码24 项目: dragonwell8_jdk   文件: KeyboardFocusManager.java
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);
}
 
源代码25 项目: openjdk-jdk8u   文件: CPlatformEmbeddedFrame.java
@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;
}
 
源代码26 项目: openjdk-jdk8u   文件: WComponentPeer.java
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;
    }
}
 
源代码27 项目: dragonwell8_jdk   文件: WComponentPeer.java
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;
    }
}
 
源代码28 项目: hottub   文件: CPlatformEmbeddedFrame.java
@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;
}
 
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;
    }
}
 
源代码30 项目: openjdk-8   文件: CPlatformEmbeddedFrame.java
@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;
}
 
 类所在包
 类方法
 同包方法