Java Code Examples for java.awt.peer.KeyboardFocusManagerPeer

The following are top voted examples for showing how to use java.awt.peer.KeyboardFocusManagerPeer. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: OpenJSharp   File: LWComponentPeer.java   View source code 5 votes vote down vote up
/**
 * Handler for FocusEvents.
 */
void handleJavaFocusEvent(final FocusEvent e) {
    // Note that the peer receives all the FocusEvents from
    // its lightweight children as well
    KeyboardFocusManagerPeer kfmPeer = LWKeyboardFocusManagerPeer.getInstance();
    kfmPeer.setCurrentFocusOwner(e.getID() == FocusEvent.FOCUS_GAINED ? getTarget() : null);
}
 
Example 2
Project: jdk8u-jdk   File: LWComponentPeer.java   View source code 5 votes vote down vote up
/**
 * Handler for FocusEvents.
 */
void handleJavaFocusEvent(final FocusEvent e) {
    // Note that the peer receives all the FocusEvents from
    // its lightweight children as well
    KeyboardFocusManagerPeer kfmPeer = LWKeyboardFocusManagerPeer.getInstance();
    kfmPeer.setCurrentFocusOwner(e.getID() == FocusEvent.FOCUS_GAINED ? getTarget() : null);
}
 
Example 3
Project: openjdk-jdk10   File: LWComponentPeer.java   View source code 5 votes vote down vote up
/**
 * Handler for FocusEvents.
 */
void handleJavaFocusEvent(final FocusEvent e) {
    // Note that the peer receives all the FocusEvents from
    // its lightweight children as well
    KeyboardFocusManagerPeer kfmPeer = LWKeyboardFocusManagerPeer.getInstance();
    kfmPeer.setCurrentFocusOwner(e.getID() == FocusEvent.FOCUS_GAINED ? getTarget() : null);
}
 
Example 4
Project: openjdk9   File: LWComponentPeer.java   View source code 5 votes vote down vote up
/**
 * Handler for FocusEvents.
 */
void handleJavaFocusEvent(final FocusEvent e) {
    // Note that the peer receives all the FocusEvents from
    // its lightweight children as well
    KeyboardFocusManagerPeer kfmPeer = LWKeyboardFocusManagerPeer.getInstance();
    kfmPeer.setCurrentFocusOwner(e.getID() == FocusEvent.FOCUS_GAINED ? getTarget() : null);
}
 
Example 5
Project: jdk8u_jdk   File: LWComponentPeer.java   View source code 5 votes vote down vote up
/**
 * Handler for FocusEvents.
 */
void handleJavaFocusEvent(final FocusEvent e) {
    // Note that the peer receives all the FocusEvents from
    // its lightweight children as well
    KeyboardFocusManagerPeer kfmPeer = LWKeyboardFocusManagerPeer.getInstance();
    kfmPeer.setCurrentFocusOwner(e.getID() == FocusEvent.FOCUS_GAINED ? getTarget() : null);
}
 
Example 6
Project: lookaside_java-1.8.0-openjdk   File: LWComponentPeer.java   View source code 5 votes vote down vote up
/**
 * Handler for FocusEvents.
 */
void handleJavaFocusEvent(final FocusEvent e) {
    // Note that the peer receives all the FocusEvents from
    // its lightweight children as well
    KeyboardFocusManagerPeer kfmPeer = LWKeyboardFocusManagerPeer.getInstance();
    kfmPeer.setCurrentFocusOwner(e.getID() == FocusEvent.FOCUS_GAINED ? getTarget() : null);
}
 
Example 7
Project: infobip-open-jdk-8   File: LWComponentPeer.java   View source code 5 votes vote down vote up
/**
 * Handler for FocusEvents.
 */
void handleJavaFocusEvent(final FocusEvent e) {
    // Note that the peer receives all the FocusEvents from
    // its lightweight children as well
    KeyboardFocusManagerPeer kfmPeer = LWKeyboardFocusManagerPeer.getInstance();
    kfmPeer.setCurrentFocusOwner(e.getID() == FocusEvent.FOCUS_GAINED ? getTarget() : null);
}
 
Example 8
Project: jdk8u-dev-jdk   File: LWComponentPeer.java   View source code 5 votes vote down vote up
/**
 * Handler for FocusEvents.
 */
void handleJavaFocusEvent(final FocusEvent e) {
    // Note that the peer receives all the FocusEvents from
    // its lightweight children as well
    KeyboardFocusManagerPeer kfmPeer = LWKeyboardFocusManagerPeer.getInstance();
    kfmPeer.setCurrentFocusOwner(e.getID() == FocusEvent.FOCUS_GAINED ? getTarget() : null);
}
 
Example 9
Project: OLD-OpenJDK8   File: LWComponentPeer.java   View source code 5 votes vote down vote up
/**
 * Handler for FocusEvents.
 */
void handleJavaFocusEvent(final FocusEvent e) {
    // Note that the peer receives all the FocusEvents from
    // its lightweight children as well
    KeyboardFocusManagerPeer kfmPeer = LWKeyboardFocusManagerPeer.getInstance();
    kfmPeer.setCurrentFocusOwner(e.getID() == FocusEvent.FOCUS_GAINED ? getTarget() : null);
}
 
Example 10
Project: openjdk-jdk7u-jdk   File: LWComponentPeer.java   View source code 5 votes vote down vote up
/**
 * Handler for FocusEvents.
 */
protected void handleJavaFocusEvent(FocusEvent e) {
    // Note that the peer receives all the FocusEvents from
    // its lightweight children as well
    KeyboardFocusManagerPeer kfmPeer = LWKeyboardFocusManagerPeer.getInstance();
    kfmPeer.setCurrentFocusOwner(e.getID() == FocusEvent.FOCUS_GAINED ? getTarget() : null);
}
 
Example 11
Project: openjdk-icedtea7   File: LWComponentPeer.java   View source code 5 votes vote down vote up
/**
 * Handler for FocusEvents.
 */
protected void handleJavaFocusEvent(FocusEvent e) {
    // Note that the peer receives all the FocusEvents from
    // its lightweight children as well
    KeyboardFocusManagerPeer kfmPeer = LWKeyboardFocusManagerPeer.getInstance();
    kfmPeer.setCurrentFocusOwner(e.getID() == FocusEvent.FOCUS_GAINED ? getTarget() : null);
}
 
Example 12
Project: openjdk-jdk10   File: HeadlessToolkit.java   View source code 4 votes vote down vote up
@Override
public KeyboardFocusManagerPeer getKeyboardFocusManagerPeer() {
    // See 6833019.
    return kfmPeer;
}
 
Example 13
Project: openjdk-jdk10   File: SunToolkit.java   View source code 4 votes vote down vote up
@Override
public abstract KeyboardFocusManagerPeer getKeyboardFocusManagerPeer()
    throws HeadlessException;
 
Example 14
Project: openjdk-jdk10   File: HToolkit.java   View source code 4 votes vote down vote up
@Override
public KeyboardFocusManagerPeer getKeyboardFocusManagerPeer() {
    // See 6833019.
    return kfmPeer;
}
 
Example 15
Project: openjdk9   File: HeadlessToolkit.java   View source code 4 votes vote down vote up
@Override
public KeyboardFocusManagerPeer getKeyboardFocusManagerPeer() {
    // See 6833019.
    return kfmPeer;
}
 
Example 16
Project: openjdk9   File: SunToolkit.java   View source code 4 votes vote down vote up
@Override
public abstract KeyboardFocusManagerPeer getKeyboardFocusManagerPeer()
    throws HeadlessException;
 
Example 17
Project: openjdk9   File: HToolkit.java   View source code 4 votes vote down vote up
@Override
public KeyboardFocusManagerPeer getKeyboardFocusManagerPeer() {
    // See 6833019.
    return kfmPeer;
}
 
Example 18
Project: openjdk-jdk7u-jdk   File: LWComponentPeer.java   View source code 4 votes vote down vote up
@Override
public boolean requestFocus(Component lightweightChild, boolean temporary,
                            boolean focusedWindowChangeAllowed, long time,
                            CausedFocusEvent.Cause cause)
{
    if (focusLog.isLoggable(PlatformLogger.FINEST)) {
        focusLog.finest("lightweightChild=" + lightweightChild + ", temporary=" + temporary +
                        ", focusedWindowChangeAllowed=" + focusedWindowChangeAllowed +
                        ", time= " + time + ", cause=" + cause);
    }
    if (LWKeyboardFocusManagerPeer.processSynchronousLightweightTransfer(
            getTarget(), lightweightChild, temporary,
            focusedWindowChangeAllowed, time)) {
        return true;
    }

    int result = LWKeyboardFocusManagerPeer.shouldNativelyFocusHeavyweight(
            getTarget(), lightweightChild, temporary,
            focusedWindowChangeAllowed, time, cause);
    switch (result) {
        case LWKeyboardFocusManagerPeer.SNFH_FAILURE:
            return false;
        case LWKeyboardFocusManagerPeer.SNFH_SUCCESS_PROCEED:
            Window parentWindow = SunToolkit.getContainingWindow(getTarget());
            if (parentWindow == null) {
                focusLog.fine("request rejected, parentWindow is null");
                LWKeyboardFocusManagerPeer.removeLastFocusRequest(getTarget());
                return false;
            }
            LWWindowPeer parentPeer = (LWWindowPeer) parentWindow.getPeer();
            if (parentPeer == null) {
                focusLog.fine("request rejected, parentPeer is null");
                LWKeyboardFocusManagerPeer.removeLastFocusRequest(getTarget());
                return false;
            }

            // A fix for 7145768. Ensure the parent window is currently natively focused.
            // The more evident place to perform this check is in KFM.shouldNativelyFocusHeavyweight,
            // however that is the shared code and this particular problem's reproducibility has
            // platform specifics. So, it was decided to narrow down the fix to lwawt (OSX) in
            // current release. TODO: consider fixing it in the shared code.
            if (!focusedWindowChangeAllowed) {
                LWWindowPeer decoratedPeer = parentPeer.isSimpleWindow() ?
                    LWWindowPeer.getOwnerFrameDialog(parentPeer) : parentPeer;

                if (decoratedPeer == null || !decoratedPeer.getPlatformWindow().isActive()) {
                    if (focusLog.isLoggable(PlatformLogger.FINE)) {
                        focusLog.fine("request rejected, focusedWindowChangeAllowed==false, " +
                                      "decoratedPeer is inactive: " + decoratedPeer);
                    }
                    LWKeyboardFocusManagerPeer.removeLastFocusRequest(getTarget());
                    return false;
                }
            }

            boolean res = parentPeer.requestWindowFocus(cause);
            // 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()) {
                if (focusLog.isLoggable(PlatformLogger.FINE)) {
                    focusLog.fine("request rejected, res= " + res + ", parentWindow.isFocused()=" +
                                  parentWindow.isFocused());
                }
                LWKeyboardFocusManagerPeer.removeLastFocusRequest(getTarget());
                return false;
            }

            KeyboardFocusManagerPeer kfmPeer = LWKeyboardFocusManagerPeer.getInstance();
            Component focusOwner = kfmPeer.getCurrentFocusOwner();
            return LWKeyboardFocusManagerPeer.deliverFocus(lightweightChild,
                    getTarget(), temporary,
                    focusedWindowChangeAllowed,
                    time, cause, focusOwner);

        case LWKeyboardFocusManagerPeer.SNFH_SUCCESS_HANDLED:
            return true;
    }

    return false;
}
 
Example 19
Project: libbluray   File: BDToolkit.java   View source code 4 votes vote down vote up
public KeyboardFocusManagerPeer createKeyboardFocusManagerPeer(KeyboardFocusManager kfm)
{
    return getKeyboardFocusManagerPeer();
}
 
Example 20
Project: libbluray   File: BDToolkit.java   View source code 4 votes vote down vote up
public KeyboardFocusManagerPeer getKeyboardFocusManagerPeer()
{
    return BDKeyboardFocusManagerPeer.getInstance();
}
 
Example 21
Project: openjdk-icedtea7   File: LWComponentPeer.java   View source code 4 votes vote down vote up
@Override
public boolean requestFocus(Component lightweightChild, boolean temporary,
                            boolean focusedWindowChangeAllowed, long time,
                            CausedFocusEvent.Cause cause)
{
    if (focusLog.isLoggable(PlatformLogger.FINEST)) {
        focusLog.finest("lightweightChild=" + lightweightChild + ", temporary=" + temporary +
                        ", focusedWindowChangeAllowed=" + focusedWindowChangeAllowed +
                        ", time= " + time + ", cause=" + cause);
    }
    if (LWKeyboardFocusManagerPeer.processSynchronousLightweightTransfer(
            getTarget(), lightweightChild, temporary,
            focusedWindowChangeAllowed, time)) {
        return true;
    }

    int result = LWKeyboardFocusManagerPeer.shouldNativelyFocusHeavyweight(
            getTarget(), lightweightChild, temporary,
            focusedWindowChangeAllowed, time, cause);
    switch (result) {
        case LWKeyboardFocusManagerPeer.SNFH_FAILURE:
            return false;
        case LWKeyboardFocusManagerPeer.SNFH_SUCCESS_PROCEED:
            Window parentWindow = SunToolkit.getContainingWindow(getTarget());
            if (parentWindow == null) {
                focusLog.fine("request rejected, parentWindow is null");
                LWKeyboardFocusManagerPeer.removeLastFocusRequest(getTarget());
                return false;
            }
            LWWindowPeer parentPeer = (LWWindowPeer) parentWindow.getPeer();
            if (parentPeer == null) {
                focusLog.fine("request rejected, parentPeer is null");
                LWKeyboardFocusManagerPeer.removeLastFocusRequest(getTarget());
                return false;
            }

            // A fix for 7145768. Ensure the parent window is currently natively focused.
            // The more evident place to perform this check is in KFM.shouldNativelyFocusHeavyweight,
            // however that is the shared code and this particular problem's reproducibility has
            // platform specifics. So, it was decided to narrow down the fix to lwawt (OSX) in
            // current release. TODO: consider fixing it in the shared code.
            if (!focusedWindowChangeAllowed) {
                LWWindowPeer decoratedPeer = parentPeer.isSimpleWindow() ?
                    LWWindowPeer.getOwnerFrameDialog(parentPeer) : parentPeer;

                if (decoratedPeer == null || !decoratedPeer.getPlatformWindow().isActive()) {
                    if (focusLog.isLoggable(PlatformLogger.FINE)) {
                        focusLog.fine("request rejected, focusedWindowChangeAllowed==false, " +
                                      "decoratedPeer is inactive: " + decoratedPeer);
                    }
                    LWKeyboardFocusManagerPeer.removeLastFocusRequest(getTarget());
                    return false;
                }
            }

            boolean res = parentPeer.requestWindowFocus(cause);
            // 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()) {
                if (focusLog.isLoggable(PlatformLogger.FINE)) {
                    focusLog.fine("request rejected, res= " + res + ", parentWindow.isFocused()=" +
                                  parentWindow.isFocused());
                }
                LWKeyboardFocusManagerPeer.removeLastFocusRequest(getTarget());
                return false;
            }

            KeyboardFocusManagerPeer kfmPeer = LWKeyboardFocusManagerPeer.getInstance();
            Component focusOwner = kfmPeer.getCurrentFocusOwner();
            return LWKeyboardFocusManagerPeer.deliverFocus(lightweightChild,
                    getTarget(), temporary,
                    focusedWindowChangeAllowed,
                    time, cause, focusOwner);

        case LWKeyboardFocusManagerPeer.SNFH_SUCCESS_HANDLED:
            return true;
    }

    return false;
}
 
Example 22
Project: OpenJSharp   File: KeyboardFocusManagerPeerProvider.java   View source code 2 votes vote down vote up
/**
 * Gets a singleton KeyboardFocusManagerPeer instance.
 */
KeyboardFocusManagerPeer getKeyboardFocusManagerPeer();
 
Example 23
Project: jdk8u-jdk   File: KeyboardFocusManagerPeerProvider.java   View source code 2 votes vote down vote up
/**
 * Gets a singleton KeyboardFocusManagerPeer instance.
 */
KeyboardFocusManagerPeer getKeyboardFocusManagerPeer();
 
Example 24
Project: openjdk-jdk10   File: KeyboardFocusManagerPeerProvider.java   View source code 2 votes vote down vote up
/**
 * Gets a singleton KeyboardFocusManagerPeer instance.
 */
KeyboardFocusManagerPeer getKeyboardFocusManagerPeer();
 
Example 25
Project: openjdk9   File: KeyboardFocusManagerPeerProvider.java   View source code 2 votes vote down vote up
/**
 * Gets a singleton KeyboardFocusManagerPeer instance.
 */
KeyboardFocusManagerPeer getKeyboardFocusManagerPeer();
 
Example 26
Project: jdk8u_jdk   File: KeyboardFocusManagerPeerProvider.java   View source code 2 votes vote down vote up
/**
 * Gets a singleton KeyboardFocusManagerPeer instance.
 */
KeyboardFocusManagerPeer getKeyboardFocusManagerPeer();
 
Example 27
Project: lookaside_java-1.8.0-openjdk   File: KeyboardFocusManagerPeerProvider.java   View source code 2 votes vote down vote up
/**
 * Gets a singleton KeyboardFocusManagerPeer instance.
 */
KeyboardFocusManagerPeer getKeyboardFocusManagerPeer();
 
Example 28
Project: infobip-open-jdk-8   File: KeyboardFocusManagerPeerProvider.java   View source code 2 votes vote down vote up
/**
 * Gets a singleton KeyboardFocusManagerPeer instance.
 */
KeyboardFocusManagerPeer getKeyboardFocusManagerPeer();
 
Example 29
Project: jdk8u-dev-jdk   File: KeyboardFocusManagerPeerProvider.java   View source code 2 votes vote down vote up
/**
 * Gets a singleton KeyboardFocusManagerPeer instance.
 */
KeyboardFocusManagerPeer getKeyboardFocusManagerPeer();
 
Example 30
Project: jdk7-jdk   File: KeyboardFocusManagerPeerProvider.java   View source code 2 votes vote down vote up
/**
 * Creates a KeyboardFocusManagerPeer for the specified KeyboardFocusManager.
 */
KeyboardFocusManagerPeer createKeyboardFocusManagerPeer(KeyboardFocusManager manager);
 
Example 31
Project: openjdk-source-code-learn   File: KeyboardFocusManagerPeerProvider.java   View source code