sun.lwawt.LWToolkit Java Examples

The following examples show how to use sun.lwawt.LWToolkit. 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: CMenuItem.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void setEnabled(boolean b) {
    final Object parent = LWToolkit.targetToPeer(getTarget().getParent());
    if (parent instanceof CMenuItem) {
        b &= ((CMenuItem) parent).isEnabled();
    }
    if (enabled.compareAndSet(!b, b)) {
        nativeSetEnabled(getModel(), b);
    }
}
 
Example #2
Source File: CMenuItem.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void setEnabled(boolean b) {
    final Object parent = LWToolkit.targetToPeer(getTarget().getParent());
    if (parent instanceof CMenuItem) {
        b &= ((CMenuItem) parent).isEnabled();
    }
    if (enabled.compareAndSet(!b, b)) {
        final boolean finalB = b;
        execute(ptr->nativeSetEnabled(ptr, finalB));
    }
}
 
Example #3
Source File: ScreenMenu.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Callback from JavaMenuUpdater.m -- called when mouse event happens on the menu.
 */
public void handleMouseEvent(final int kind, final int x, final int y, final int modifiers, final long when) {
    if (kind == 0) return;
    if (fItemBounds == null) return;

    SunToolkit.executeOnEventHandlerThread(fInvoker, new Runnable() {
        @Override
        public void run() {
            Component target = null;
            Rectangle targetRect = null;
            for (int i = 0; i < fItemBounds.length; i++) {
                final Rectangle testRect = fItemBounds[i];
                if (testRect != null) {
                    if (testRect.contains(x, y)) {
                        target = fInvoker.getMenuComponent(i);
                        targetRect = testRect;
                        break;
                    }
                }
            }
            if (target == null && fLastMouseEventTarget == null) return;

            // Send a mouseExited to the previously hilited item, if it wasn't 0.
            if (target != fLastMouseEventTarget) {
                if (fLastMouseEventTarget != null) {
                    LWToolkit.postEvent(new MouseEvent(fLastMouseEventTarget, MouseEvent.MOUSE_EXITED, when, modifiers, x - fLastTargetRect.x, y - fLastTargetRect.y, 0, false));
                }
                // Send a mouseEntered to the current hilited item, if it wasn't 0.
                if (target != null) {
                    LWToolkit.postEvent(new MouseEvent(target, MouseEvent.MOUSE_ENTERED, when, modifiers, x - targetRect.x, y - targetRect.y, 0, false));
                }
                fLastMouseEventTarget = target;
                fLastTargetRect = targetRect;
            }
            // Post a mouse event to the current item.
            if (target == null) return;
            LWToolkit.postEvent(new MouseEvent(target, kind, when, modifiers, x - targetRect.x, y - targetRect.y, 0, false));
        }
    });
}
 
Example #4
Source File: CMenuItem.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void setEnabled(boolean b) {
    final Object parent = LWToolkit.targetToPeer(getTarget().getParent());
    if (parent instanceof CMenuItem) {
        b &= ((CMenuItem) parent).isEnabled();
    }
    if (enabled.compareAndSet(!b, b)) {
        nativeSetEnabled(getModel(), b);
    }
}
 
Example #5
Source File: ScreenMenu.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Callback from JavaMenuUpdater.m -- called when mouse event happens on the menu.
 */
public void handleMouseEvent(final int kind, final int x, final int y, final int modifiers, final long when) {
    if (kind == 0) return;
    if (fItemBounds == null) return;

    SunToolkit.executeOnEventHandlerThread(fInvoker, new Runnable() {
        @Override
        public void run() {
            Component target = null;
            Rectangle targetRect = null;
            for (int i = 0; i < fItemBounds.length; i++) {
                final Rectangle testRect = fItemBounds[i];
                if (testRect != null) {
                    if (testRect.contains(x, y)) {
                        target = fInvoker.getMenuComponent(i);
                        targetRect = testRect;
                        break;
                    }
                }
            }
            if (target == null && fLastMouseEventTarget == null) return;

            // Send a mouseExited to the previously hilited item, if it wasn't 0.
            if (target != fLastMouseEventTarget) {
                if (fLastMouseEventTarget != null) {
                    LWToolkit.postEvent(new MouseEvent(fLastMouseEventTarget, MouseEvent.MOUSE_EXITED, when, modifiers, x - fLastTargetRect.x, y - fLastTargetRect.y, 0, false));
                }
                // Send a mouseEntered to the current hilited item, if it wasn't 0.
                if (target != null) {
                    LWToolkit.postEvent(new MouseEvent(target, MouseEvent.MOUSE_ENTERED, when, modifiers, x - targetRect.x, y - targetRect.y, 0, false));
                }
                fLastMouseEventTarget = target;
                fLastTargetRect = targetRect;
            }
            // Post a mouse event to the current item.
            if (target == null) return;
            LWToolkit.postEvent(new MouseEvent(target, kind, when, modifiers, x - targetRect.x, y - targetRect.y, 0, false));
        }
    });
}
 
Example #6
Source File: CEmbeddedFrame.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public void addNotify() {
    if (getPeer() == null) {
        LWToolkit toolkit = (LWToolkit)Toolkit.getDefaultToolkit();
        LWWindowPeer peer = toolkit.createEmbeddedFrame(this);
        setPeer(peer);
        responder = new CPlatformResponder(peer, true);
    }
    super.addNotify();
}
 
Example #7
Source File: CMenuItem.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void setEnabled(boolean b) {
    final Object parent = LWToolkit.targetToPeer(getTarget().getParent());
    if (parent instanceof CMenuItem) {
        b &= ((CMenuItem) parent).isEnabled();
    }
    if (enabled.compareAndSet(!b, b)) {
        nativeSetEnabled(getModel(), b);
    }
}
 
Example #8
Source File: CViewEmbeddedFrame.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
public void addNotify() {
    if (getPeer() == null) {
        LWToolkit toolkit = (LWToolkit) Toolkit.getDefaultToolkit();
        setPeer(toolkit.createEmbeddedFrame(this));
    }
    super.addNotify();
}
 
Example #9
Source File: ScreenMenu.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Callback from JavaMenuUpdater.m -- called when mouse event happens on the menu.
 */
public void handleMouseEvent(final int kind, final int x, final int y, final int modifiers, final long when) {
    if (kind == 0) return;
    if (fItemBounds == null) return;

    SunToolkit.executeOnEventHandlerThread(fInvoker, new Runnable() {
        @Override
        public void run() {
            Component target = null;
            Rectangle targetRect = null;
            for (int i = 0; i < fItemBounds.length; i++) {
                final Rectangle testRect = fItemBounds[i];
                if (testRect != null) {
                    if (testRect.contains(x, y)) {
                        target = fInvoker.getMenuComponent(i);
                        targetRect = testRect;
                        break;
                    }
                }
            }
            if (target == null && fLastMouseEventTarget == null) return;

            // Send a mouseExited to the previously hilited item, if it wasn't 0.
            if (target != fLastMouseEventTarget) {
                if (fLastMouseEventTarget != null) {
                    LWToolkit.postEvent(new MouseEvent(fLastMouseEventTarget, MouseEvent.MOUSE_EXITED, when, modifiers, x - fLastTargetRect.x, y - fLastTargetRect.y, 0, false));
                }
                // Send a mouseEntered to the current hilited item, if it wasn't 0.
                if (target != null) {
                    LWToolkit.postEvent(new MouseEvent(target, MouseEvent.MOUSE_ENTERED, when, modifiers, x - targetRect.x, y - targetRect.y, 0, false));
                }
                fLastMouseEventTarget = target;
                fLastTargetRect = targetRect;
            }
            // Post a mouse event to the current item.
            if (target == null) return;
            LWToolkit.postEvent(new MouseEvent(target, kind, when, modifiers, x - targetRect.x, y - targetRect.y, 0, false));
        }
    });
}
 
Example #10
Source File: CEmbeddedFrame.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public void addNotify() {
    if (getPeer() == null) {
        LWToolkit toolkit = (LWToolkit)Toolkit.getDefaultToolkit();
        LWWindowPeer peer = toolkit.createEmbeddedFrame(this);
        setPeer(peer);
        responder = new CPlatformResponder(peer, true);
    }
    super.addNotify();
}
 
Example #11
Source File: CMenuItem.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void setEnabled(boolean b) {
    final Object parent = LWToolkit.targetToPeer(getTarget().getParent());
    if (parent instanceof CMenuItem) {
        b &= ((CMenuItem) parent).isEnabled();
    }
    if (enabled.compareAndSet(!b, b)) {
        final boolean finalB = b;
        execute(ptr->nativeSetEnabled(ptr, finalB));
    }
}
 
Example #12
Source File: CViewEmbeddedFrame.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
public void addNotify() {
    if (getPeer() == null) {
        LWToolkit toolkit = (LWToolkit) Toolkit.getDefaultToolkit();
        setPeer(toolkit.createEmbeddedFrame(this));
    }
    super.addNotify();
}
 
Example #13
Source File: ScreenMenu.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Callback from JavaMenuUpdater.m -- called when mouse event happens on the menu.
 */
public void handleMouseEvent(final int kind, final int x, final int y, final int modifiers, final long when) {
    if (kind == 0) return;
    if (fItemBounds == null) return;

    SunToolkit.executeOnEventHandlerThread(fInvoker, new Runnable() {
        @Override
        public void run() {
            Component target = null;
            Rectangle targetRect = null;
            for (int i = 0; i < fItemBounds.length; i++) {
                final Rectangle testRect = fItemBounds[i];
                if (testRect != null) {
                    if (testRect.contains(x, y)) {
                        target = fInvoker.getMenuComponent(i);
                        targetRect = testRect;
                        break;
                    }
                }
            }
            if (target == null && fLastMouseEventTarget == null) return;

            // Send a mouseExited to the previously hilited item, if it wasn't 0.
            if (target != fLastMouseEventTarget) {
                if (fLastMouseEventTarget != null) {
                    LWToolkit.postEvent(new MouseEvent(fLastMouseEventTarget, MouseEvent.MOUSE_EXITED, when, modifiers, x - fLastTargetRect.x, y - fLastTargetRect.y, 0, false));
                }
                // Send a mouseEntered to the current hilited item, if it wasn't 0.
                if (target != null) {
                    LWToolkit.postEvent(new MouseEvent(target, MouseEvent.MOUSE_ENTERED, when, modifiers, x - targetRect.x, y - targetRect.y, 0, false));
                }
                fLastMouseEventTarget = target;
                fLastTargetRect = targetRect;
            }
            // Post a mouse event to the current item.
            if (target == null) return;
            LWToolkit.postEvent(new MouseEvent(target, kind, when, modifiers, x - targetRect.x, y - targetRect.y, 0, false));
        }
    });
}
 
Example #14
Source File: CMenuItem.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void setEnabled(boolean b) {
    final Object parent = LWToolkit.targetToPeer(getTarget().getParent());
    if (parent instanceof CMenuItem) {
        b &= ((CMenuItem) parent).isEnabled();
    }
    if (enabled.compareAndSet(!b, b)) {
        final boolean finalB = b;
        execute(ptr->nativeSetEnabled(ptr, finalB));
    }
}
 
Example #15
Source File: ScreenMenu.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Callback from JavaMenuUpdater.m -- called when mouse event happens on the menu.
 */
public void handleMouseEvent(final int kind, final int x, final int y, final int modifiers, final long when) {
    if (kind == 0) return;
    if (fItemBounds == null) return;

    SunToolkit.executeOnEventHandlerThread(fInvoker, new Runnable() {
        @Override
        public void run() {
            Component target = null;
            Rectangle targetRect = null;
            for (int i = 0; i < fItemBounds.length; i++) {
                final Rectangle testRect = fItemBounds[i];
                if (testRect != null) {
                    if (testRect.contains(x, y)) {
                        target = fInvoker.getMenuComponent(i);
                        targetRect = testRect;
                        break;
                    }
                }
            }
            if (target == null && fLastMouseEventTarget == null) return;

            // Send a mouseExited to the previously hilited item, if it wasn't 0.
            if (target != fLastMouseEventTarget) {
                if (fLastMouseEventTarget != null) {
                    LWToolkit.postEvent(new MouseEvent(fLastMouseEventTarget, MouseEvent.MOUSE_EXITED, when, modifiers, x - fLastTargetRect.x, y - fLastTargetRect.y, 0, false));
                }
                // Send a mouseEntered to the current hilited item, if it wasn't 0.
                if (target != null) {
                    LWToolkit.postEvent(new MouseEvent(target, MouseEvent.MOUSE_ENTERED, when, modifiers, x - targetRect.x, y - targetRect.y, 0, false));
                }
                fLastMouseEventTarget = target;
                fLastTargetRect = targetRect;
            }
            // Post a mouse event to the current item.
            if (target == null) return;
            LWToolkit.postEvent(new MouseEvent(target, kind, when, modifiers, x - targetRect.x, y - targetRect.y, 0, false));
        }
    });
}
 
Example #16
Source File: CMenuItem.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void setEnabled(boolean b) {
    final Object parent = LWToolkit.targetToPeer(getTarget().getParent());
    if (parent instanceof CMenuItem) {
        b &= ((CMenuItem) parent).isEnabled();
    }
    if (enabled.compareAndSet(!b, b)) {
        nativeSetEnabled(getModel(), b);
    }
}
 
Example #17
Source File: ScreenMenu.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Callback from JavaMenuUpdater.m -- called when mouse event happens on the menu.
 */
public void handleMouseEvent(final int kind, final int x, final int y, final int modifiers, final long when) {
    if (kind == 0) return;
    if (fItemBounds == null) return;

    SunToolkit.executeOnEventHandlerThread(fInvoker, new Runnable() {
        @Override
        public void run() {
            Component target = null;
            Rectangle targetRect = null;
            for (int i = 0; i < fItemBounds.length; i++) {
                final Rectangle testRect = fItemBounds[i];
                if (testRect != null) {
                    if (testRect.contains(x, y)) {
                        target = fInvoker.getMenuComponent(i);
                        targetRect = testRect;
                        break;
                    }
                }
            }
            if (target == null && fLastMouseEventTarget == null) return;

            // Send a mouseExited to the previously hilited item, if it wasn't 0.
            if (target != fLastMouseEventTarget) {
                if (fLastMouseEventTarget != null) {
                    LWToolkit.postEvent(new MouseEvent(fLastMouseEventTarget, MouseEvent.MOUSE_EXITED, when, modifiers, x - fLastTargetRect.x, y - fLastTargetRect.y, 0, false));
                }
                // Send a mouseEntered to the current hilited item, if it wasn't 0.
                if (target != null) {
                    LWToolkit.postEvent(new MouseEvent(target, MouseEvent.MOUSE_ENTERED, when, modifiers, x - targetRect.x, y - targetRect.y, 0, false));
                }
                fLastMouseEventTarget = target;
                fLastTargetRect = targetRect;
            }
            // Post a mouse event to the current item.
            if (target == null) return;
            LWToolkit.postEvent(new MouseEvent(target, kind, when, modifiers, x - targetRect.x, y - targetRect.y, 0, false));
        }
    });
}
 
Example #18
Source File: CMenuItem.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void setEnabled(boolean b) {
    final Object parent = LWToolkit.targetToPeer(getTarget().getParent());
    if (parent instanceof CMenuItem) {
        b &= ((CMenuItem) parent).isEnabled();
    }
    if (enabled.compareAndSet(!b, b)) {
        nativeSetEnabled(getModel(), b);
    }
}
 
Example #19
Source File: ScreenMenu.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Callback from JavaMenuUpdater.m -- called when mouse event happens on the menu.
 */
public void handleMouseEvent(final int kind, final int x, final int y, final int modifiers, final long when) {
    if (kind == 0) return;
    if (fItemBounds == null) return;

    SunToolkit.executeOnEventHandlerThread(fInvoker, new Runnable() {
        @Override
        public void run() {
            Component target = null;
            Rectangle targetRect = null;
            for (int i = 0; i < fItemBounds.length; i++) {
                final Rectangle testRect = fItemBounds[i];
                if (testRect != null) {
                    if (testRect.contains(x, y)) {
                        target = fInvoker.getMenuComponent(i);
                        targetRect = testRect;
                        break;
                    }
                }
            }
            if (target == null && fLastMouseEventTarget == null) return;

            // Send a mouseExited to the previously hilited item, if it wasn't 0.
            if (target != fLastMouseEventTarget) {
                if (fLastMouseEventTarget != null) {
                    LWToolkit.postEvent(new MouseEvent(fLastMouseEventTarget, MouseEvent.MOUSE_EXITED, when, modifiers, x - fLastTargetRect.x, y - fLastTargetRect.y, 0, false));
                }
                // Send a mouseEntered to the current hilited item, if it wasn't 0.
                if (target != null) {
                    LWToolkit.postEvent(new MouseEvent(target, MouseEvent.MOUSE_ENTERED, when, modifiers, x - targetRect.x, y - targetRect.y, 0, false));
                }
                fLastMouseEventTarget = target;
                fLastTargetRect = targetRect;
            }
            // Post a mouse event to the current item.
            if (target == null) return;
            LWToolkit.postEvent(new MouseEvent(target, kind, when, modifiers, x - targetRect.x, y - targetRect.y, 0, false));
        }
    });
}
 
Example #20
Source File: ScreenMenu.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Callback from JavaMenuUpdater.m -- called when mouse event happens on the menu.
 */
public void handleMouseEvent(final int kind, final int x, final int y, final int modifiers, final long when) {
    if (kind == 0) return;
    if (fItemBounds == null) return;

    SunToolkit.executeOnEventHandlerThread(fInvoker, new Runnable() {
        @Override
        public void run() {
            Component target = null;
            Rectangle targetRect = null;
            for (int i = 0; i < fItemBounds.length; i++) {
                final Rectangle testRect = fItemBounds[i];
                if (testRect != null) {
                    if (testRect.contains(x, y)) {
                        target = fInvoker.getMenuComponent(i);
                        targetRect = testRect;
                        break;
                    }
                }
            }
            if (target == null && fLastMouseEventTarget == null) return;

            // Send a mouseExited to the previously hilited item, if it wasn't 0.
            if (target != fLastMouseEventTarget) {
                if (fLastMouseEventTarget != null) {
                    LWToolkit.postEvent(new MouseEvent(fLastMouseEventTarget, MouseEvent.MOUSE_EXITED, when, modifiers, x - fLastTargetRect.x, y - fLastTargetRect.y, 0, false));
                }
                // Send a mouseEntered to the current hilited item, if it wasn't 0.
                if (target != null) {
                    LWToolkit.postEvent(new MouseEvent(target, MouseEvent.MOUSE_ENTERED, when, modifiers, x - targetRect.x, y - targetRect.y, 0, false));
                }
                fLastMouseEventTarget = target;
                fLastTargetRect = targetRect;
            }
            // Post a mouse event to the current item.
            if (target == null) return;
            LWToolkit.postEvent(new MouseEvent(target, kind, when, modifiers, x - targetRect.x, y - targetRect.y, 0, false));
        }
    });
}
 
Example #21
Source File: CMenuItem.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void setEnabled(boolean b) {
    final Object parent = LWToolkit.targetToPeer(getTarget().getParent());
    if (parent instanceof CMenuItem) {
        b &= ((CMenuItem) parent).isEnabled();
    }
    if (enabled.compareAndSet(!b, b)) {
        final boolean finalB = b;
        execute(ptr->nativeSetEnabled(ptr, finalB));
    }
}
 
Example #22
Source File: ScreenMenu.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Callback from JavaMenuUpdater.m -- called when mouse event happens on the menu.
 */
public void handleMouseEvent(final int kind, final int x, final int y, final int modifiers, final long when) {
    if (kind == 0) return;
    if (fItemBounds == null) return;

    SunToolkit.executeOnEventHandlerThread(fInvoker, new Runnable() {
        @Override
        public void run() {
            Component target = null;
            Rectangle targetRect = null;
            for (int i = 0; i < fItemBounds.length; i++) {
                final Rectangle testRect = fItemBounds[i];
                if (testRect != null) {
                    if (testRect.contains(x, y)) {
                        target = fInvoker.getMenuComponent(i);
                        targetRect = testRect;
                        break;
                    }
                }
            }
            if (target == null && fLastMouseEventTarget == null) return;

            // Send a mouseExited to the previously hilited item, if it wasn't 0.
            if (target != fLastMouseEventTarget) {
                if (fLastMouseEventTarget != null) {
                    LWToolkit.postEvent(new MouseEvent(fLastMouseEventTarget, MouseEvent.MOUSE_EXITED, when, modifiers, x - fLastTargetRect.x, y - fLastTargetRect.y, 0, false));
                }
                // Send a mouseEntered to the current hilited item, if it wasn't 0.
                if (target != null) {
                    LWToolkit.postEvent(new MouseEvent(target, MouseEvent.MOUSE_ENTERED, when, modifiers, x - targetRect.x, y - targetRect.y, 0, false));
                }
                fLastMouseEventTarget = target;
                fLastTargetRect = targetRect;
            }
            // Post a mouse event to the current item.
            if (target == null) return;
            LWToolkit.postEvent(new MouseEvent(target, kind, when, modifiers, x - targetRect.x, y - targetRect.y, 0, false));
        }
    });
}
 
Example #23
Source File: CMenuItem.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void setEnabled(boolean b) {
    final Object parent = LWToolkit.targetToPeer(getTarget().getParent());
    if (parent instanceof CMenuItem) {
        b &= ((CMenuItem) parent).isEnabled();
    }
    if (enabled.compareAndSet(!b, b)) {
        final boolean finalB = b;
        execute(ptr->nativeSetEnabled(ptr, finalB));
    }
}
 
Example #24
Source File: CMenuItem.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void setEnabled(boolean b) {
    final Object parent = LWToolkit.targetToPeer(getTarget().getParent());
    if (parent instanceof CMenuItem) {
        b &= ((CMenuItem) parent).isEnabled();
    }
    if (enabled.compareAndSet(!b, b)) {
        final boolean finalB = b;
        execute(ptr->nativeSetEnabled(ptr, finalB));
    }
}
 
Example #25
Source File: ScreenMenu.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Callback from JavaMenuUpdater.m -- called when mouse event happens on the menu.
 */
public void handleMouseEvent(final int kind, final int x, final int y, final int modifiers, final long when) {
    if (kind == 0) return;
    if (fItemBounds == null) return;

    SunToolkit.executeOnEventHandlerThread(fInvoker, new Runnable() {
        @Override
        public void run() {
            Component target = null;
            Rectangle targetRect = null;
            for (int i = 0; i < fItemBounds.length; i++) {
                final Rectangle testRect = fItemBounds[i];
                if (testRect != null) {
                    if (testRect.contains(x, y)) {
                        target = fInvoker.getMenuComponent(i);
                        targetRect = testRect;
                        break;
                    }
                }
            }
            if (target == null && fLastMouseEventTarget == null) return;

            // Send a mouseExited to the previously hilited item, if it wasn't 0.
            if (target != fLastMouseEventTarget) {
                if (fLastMouseEventTarget != null) {
                    LWToolkit.postEvent(new MouseEvent(fLastMouseEventTarget, MouseEvent.MOUSE_EXITED, when, modifiers, x - fLastTargetRect.x, y - fLastTargetRect.y, 0, false));
                }
                // Send a mouseEntered to the current hilited item, if it wasn't 0.
                if (target != null) {
                    LWToolkit.postEvent(new MouseEvent(target, MouseEvent.MOUSE_ENTERED, when, modifiers, x - targetRect.x, y - targetRect.y, 0, false));
                }
                fLastMouseEventTarget = target;
                fLastTargetRect = targetRect;
            }
            // Post a mouse event to the current item.
            if (target == null) return;
            LWToolkit.postEvent(new MouseEvent(target, kind, when, modifiers, x - targetRect.x, y - targetRect.y, 0, false));
        }
    });
}
 
Example #26
Source File: CMenuItem.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void setEnabled(boolean b) {
    final Object parent = LWToolkit.targetToPeer(getTarget().getParent());
    if (parent instanceof CMenuItem) {
        b &= ((CMenuItem) parent).isEnabled();
    }
    if (enabled.compareAndSet(!b, b)) {
        final boolean finalB = b;
        execute(ptr->nativeSetEnabled(ptr, finalB));
    }
}
 
Example #27
Source File: ScreenMenu.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Callback from JavaMenuUpdater.m -- called when mouse event happens on the menu.
 */
public void handleMouseEvent(final int kind, final int x, final int y, final int modifiers, final long when) {
    if (kind == 0) return;
    if (fItemBounds == null) return;

    SunToolkit.executeOnEventHandlerThread(fInvoker, new Runnable() {
        @Override
        public void run() {
            Component target = null;
            Rectangle targetRect = null;
            for (int i = 0; i < fItemBounds.length; i++) {
                final Rectangle testRect = fItemBounds[i];
                if (testRect != null) {
                    if (testRect.contains(x, y)) {
                        target = fInvoker.getMenuComponent(i);
                        targetRect = testRect;
                        break;
                    }
                }
            }
            if (target == null && fLastMouseEventTarget == null) return;

            // Send a mouseExited to the previously hilited item, if it wasn't 0.
            if (target != fLastMouseEventTarget) {
                if (fLastMouseEventTarget != null) {
                    LWToolkit.postEvent(new MouseEvent(fLastMouseEventTarget, MouseEvent.MOUSE_EXITED, when, modifiers, x - fLastTargetRect.x, y - fLastTargetRect.y, 0, false));
                }
                // Send a mouseEntered to the current hilited item, if it wasn't 0.
                if (target != null) {
                    LWToolkit.postEvent(new MouseEvent(target, MouseEvent.MOUSE_ENTERED, when, modifiers, x - targetRect.x, y - targetRect.y, 0, false));
                }
                fLastMouseEventTarget = target;
                fLastTargetRect = targetRect;
            }
            // Post a mouse event to the current item.
            if (target == null) return;
            LWToolkit.postEvent(new MouseEvent(target, kind, when, modifiers, x - targetRect.x, y - targetRect.y, 0, false));
        }
    });
}
 
Example #28
Source File: ScreenMenu.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Callback from JavaMenuUpdater.m -- called when mouse event happens on the menu.
 */
public void handleMouseEvent(final int kind, final int x, final int y, final int modifiers, final long when) {
    if (kind == 0) return;
    if (fItemBounds == null) return;

    SunToolkit.executeOnEventHandlerThread(fInvoker, new Runnable() {
        @Override
        public void run() {
            Component target = null;
            Rectangle targetRect = null;
            for (int i = 0; i < fItemBounds.length; i++) {
                final Rectangle testRect = fItemBounds[i];
                if (testRect != null) {
                    if (testRect.contains(x, y)) {
                        target = fInvoker.getMenuComponent(i);
                        targetRect = testRect;
                        break;
                    }
                }
            }
            if (target == null && fLastMouseEventTarget == null) return;

            // Send a mouseExited to the previously hilited item, if it wasn't 0.
            if (target != fLastMouseEventTarget) {
                if (fLastMouseEventTarget != null) {
                    LWToolkit.postEvent(new MouseEvent(fLastMouseEventTarget, MouseEvent.MOUSE_EXITED, when, modifiers, x - fLastTargetRect.x, y - fLastTargetRect.y, 0, false));
                }
                // Send a mouseEntered to the current hilited item, if it wasn't 0.
                if (target != null) {
                    LWToolkit.postEvent(new MouseEvent(target, MouseEvent.MOUSE_ENTERED, when, modifiers, x - targetRect.x, y - targetRect.y, 0, false));
                }
                fLastMouseEventTarget = target;
                fLastTargetRect = targetRect;
            }
            // Post a mouse event to the current item.
            if (target == null) return;
            LWToolkit.postEvent(new MouseEvent(target, kind, when, modifiers, x - targetRect.x, y - targetRect.y, 0, false));
        }
    });
}
 
Example #29
Source File: CMenuItem.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void setEnabled(boolean b) {
    final Object parent = LWToolkit.targetToPeer(getTarget().getParent());
    if (parent instanceof CMenuItem) {
        b &= ((CMenuItem) parent).isEnabled();
    }
    if (enabled.compareAndSet(!b, b)) {
        nativeSetEnabled(getModel(), b);
    }
}
 
Example #30
Source File: CMenuItem.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
@Override
long createModel() {
    CMenuComponent parent = (CMenuComponent)LWToolkit.targetToPeer(getTarget().getParent());
    return parent.executeGet(ptr->nativeCreate(ptr, isSeparator()));
}