java.awt.peer.MenuComponentPeer Java Examples

The following examples show how to use java.awt.peer.MenuComponentPeer. 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: ScreenMenuItem.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
static void syncLabelAndKS(MenuItem menuItem, String label, KeyStroke ks) {
    final MenuComponentPeer peer = menuItem.getPeer();
    if (!(peer instanceof CMenuItem)) {
        //Is it possible?
        return;
    }
    final CMenuItem cmi = (CMenuItem) peer;
    if (ks == null) {
        cmi.setLabel(label);
    } else {
        cmi.setLabel(label, ks.getKeyChar(), ks.getKeyCode(),
                     ks.getModifiers());
    }
}
 
Example #2
Source File: ScreenMenuItem.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
static void syncLabelAndKS(MenuItem menuItem, String label, KeyStroke ks) {
    final MenuComponentPeer peer = menuItem.getPeer();
    if (!(peer instanceof CMenuItem)) {
        //Is it possible?
        return;
    }
    final CMenuItem cmi = (CMenuItem) peer;
    if (ks == null) {
        cmi.setLabel(label);
    } else {
        cmi.setLabel(label, ks.getKeyChar(), ks.getKeyCode(),
                     ks.getModifiers());
    }
}
 
Example #3
Source File: MenuComponent.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Removes the menu component's peer.  The peer allows us to modify the
 * appearance of the menu component without changing the functionality of
 * the menu component.
 */
public void removeNotify() {
    synchronized (getTreeLock()) {
        MenuComponentPeer p = this.peer;
        if (p != null) {
            Toolkit.getEventQueue().removeSourceEvents(this, true);
            this.peer = null;
            p.dispose();
        }
    }
}
 
Example #4
Source File: ScreenMenuItem.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
static void syncLabelAndKS(MenuItem menuItem, String label, KeyStroke ks) {
    final MenuComponentPeer peer = menuItem.getPeer();
    if (!(peer instanceof CMenuItem)) {
        //Is it possible?
        return;
    }
    final CMenuItem cmi = (CMenuItem) peer;
    if (ks == null) {
        cmi.setLabel(label);
    } else {
        cmi.setLabel(label, ks.getKeyChar(), ks.getKeyCode(),
                     ks.getModifiers());
    }
}
 
Example #5
Source File: ScreenMenuItem.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
static void syncLabelAndKS(MenuItem menuItem, String label, KeyStroke ks) {
    final MenuComponentPeer peer = menuItem.getPeer();
    if (!(peer instanceof CMenuItem)) {
        //Is it possible?
        return;
    }
    final CMenuItem cmi = (CMenuItem) peer;
    if (ks == null) {
        cmi.setLabel(label);
    } else {
        cmi.setLabel(label, ks.getKeyChar(), ks.getKeyCode(),
                     ks.getModifiers());
    }
}
 
Example #6
Source File: ScreenMenuItem.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void setIcon(final Icon i) {
final MenuComponentPeer peer = getPeer();
if (!(peer instanceof CMenuItem)) return;

final CMenuItem cmi = (CMenuItem)peer;
    Image img = null;

if (i != null) {
    if (i.getIconWidth() > 0 && i.getIconHeight() > 0) {
            img = AquaIcon.getImageForIcon(i);
        }
}
    cmi.setImage(img);
}
 
Example #7
Source File: MenuComponent.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Removes the menu component's peer.  The peer allows us to modify the
 * appearance of the menu component without changing the functionality of
 * the menu component.
 */
public void removeNotify() {
    synchronized (getTreeLock()) {
        MenuComponentPeer p = this.peer;
        if (p != null) {
            Toolkit.getEventQueue().removeSourceEvents(this, true);
            this.peer = null;
            p.dispose();
        }
    }
}
 
Example #8
Source File: ScreenMenuItemCheckbox.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void setIcon(final Icon i) {
    final MenuComponentPeer peer = getPeer();
    if (!(peer instanceof CMenuItem)) return;

    final CMenuItem cmi = (CMenuItem)peer;
    Image img = null;

    if (i != null) {
        if (i.getIconWidth() > 0 && i.getIconHeight() > 0) {
            img = AquaIcon.getImageForIcon(i);
        }
    }
    cmi.setImage(img);
}
 
Example #9
Source File: ScreenMenuItem.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
static void syncLabelAndKS(MenuItem menuItem, String label, KeyStroke ks) {
    final MenuComponentPeer peer = menuItem.getPeer();
    if (!(peer instanceof CMenuItem)) {
        //Is it possible?
        return;
    }
    final CMenuItem cmi = (CMenuItem) peer;
    if (ks == null) {
        cmi.setLabel(label);
    } else {
        cmi.setLabel(label, ks.getKeyChar(), ks.getKeyCode(),
                     ks.getModifiers());
    }
}
 
Example #10
Source File: MenuComponent.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Removes the menu component's peer.  The peer allows us to modify the
 * appearance of the menu component without changing the functionality of
 * the menu component.
 */
public void removeNotify() {
    synchronized (getTreeLock()) {
        MenuComponentPeer p = this.peer;
        if (p != null) {
            Toolkit.getEventQueue().removeSourceEvents(this, true);
            this.peer = null;
            p.dispose();
        }
    }
}
 
Example #11
Source File: ScreenMenu.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void setToolTipText(final String text) {
    final MenuComponentPeer peer = getPeer();
    if (!(peer instanceof CMenuItem)) return;

    final CMenuItem cmi = (CMenuItem)peer;
    cmi.setToolTipText(text);
}
 
Example #12
Source File: _AppMenuBarHandler.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
static void installDefaultMenuBar(final JMenuBar menuBar) {
    if (menuBar == null) {
        // intentionally clearing the default menu
        nativeSetDefaultMenuBar(0);
        return;
    }

    final MenuBarUI ui = menuBar.getUI();
    if (!(ui instanceof AquaMenuBarUI)) {
        // Aqua was not installed
        throw new IllegalStateException("Application.setDefaultMenuBar() only works with the Aqua Look and Feel");
    }

    final AquaMenuBarUI aquaUI = (AquaMenuBarUI)ui;
    final ScreenMenuBar screenMenuBar = aquaUI.getScreenMenuBar();
    if (screenMenuBar == null) {
        // Aqua is installed, but we aren't using the screen menu bar
        throw new IllegalStateException("Application.setDefaultMenuBar() only works if apple.laf.useScreenMenuBar=true");
    }

    screenMenuBar.addNotify();
    final MenuComponentPeer peer = screenMenuBar.getPeer();
    if (!(peer instanceof CMenuBar)) {
        // such a thing should not be possible
        throw new IllegalStateException("Unable to determine native menu bar from provided JMenuBar");
    }

    // grab the pointer to the CMenuBar, and retain it in native
    nativeSetDefaultMenuBar(((CMenuBar)peer).getModel());
}
 
Example #13
Source File: ScreenMenuItem.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public void setIcon(final Icon i) {
final MenuComponentPeer peer = getPeer();
if (!(peer instanceof CMenuItem)) return;

final CMenuItem cmi = (CMenuItem)peer;
    Image img = null;

if (i != null) {
    if (i.getIconWidth() > 0 && i.getIconHeight() > 0) {
            img = AquaIcon.getImageForIcon(i);
        }
}
    cmi.setImage(img);
}
 
Example #14
Source File: ScreenMenu.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void setToolTipText(final String text) {
    final MenuComponentPeer peer = getPeer();
    if (!(peer instanceof CMenuItem)) return;

    final CMenuItem cmi = (CMenuItem)peer;
    cmi.setToolTipText(text);
}
 
Example #15
Source File: ScreenMenuItem.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
static void syncLabelAndKS(MenuItem menuItem, String label, KeyStroke ks) {
    final MenuComponentPeer peer = menuItem.getPeer();
    if (!(peer instanceof CMenuItem)) {
        //Is it possible?
        return;
    }
    final CMenuItem cmi = (CMenuItem) peer;
    if (ks == null) {
        cmi.setLabel(label);
    } else {
        cmi.setLabel(label, ks.getKeyChar(), ks.getKeyCode(),
                     ks.getModifiers());
    }
}
 
Example #16
Source File: ScreenMenuItem.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
static void syncLabelAndKS(MenuItem menuItem, String label, KeyStroke ks) {
    final MenuComponentPeer peer = menuItem.getPeer();
    if (!(peer instanceof CMenuItem)) {
        //Is it possible?
        return;
    }
    final CMenuItem cmi = (CMenuItem) peer;
    if (ks == null) {
        cmi.setLabel(label);
    } else {
        cmi.setLabel(label, ks.getKeyChar(), ks.getKeyCode(),
                     ks.getModifiers());
    }
}
 
Example #17
Source File: ScreenMenu.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void addNotify() {
    synchronized (getTreeLock()) {
        super.addNotify();
        if (fModelPtr == 0) {
            fInvoker.addContainerListener(this);
            fInvoker.addComponentListener(this);
            fPropertyListener = new ScreenMenuPropertyListener(this);
            fInvoker.addPropertyChangeListener(fPropertyListener);

            final Icon icon = fInvoker.getIcon();
            if (icon != null) {
                setIcon(icon);
            }

            final String tooltipText = fInvoker.getToolTipText();
            if (tooltipText != null) {
                setToolTipText(tooltipText);
            }
            final MenuComponentPeer peer = getPeer();
            if (peer instanceof CMenu) {
                final CMenu menu = (CMenu) peer;
                final long nativeMenu = menu.getNativeMenu();
                fModelPtr = addMenuListeners(this, nativeMenu);
            }
        }
    }
}
 
Example #18
Source File: ScreenMenuItem.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void setIcon(final Icon i) {
final MenuComponentPeer peer = getPeer();
if (!(peer instanceof CMenuItem)) return;

final CMenuItem cmi = (CMenuItem)peer;
    Image img = null;

if (i != null) {
    if (i.getIconWidth() > 0 && i.getIconHeight() > 0) {
            img = AquaIcon.getImageForIcon(i);
        }
}
    cmi.setImage(img);
}
 
Example #19
Source File: ScreenMenu.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void setIcon(final Icon i) {
    final MenuComponentPeer peer = getPeer();
    if (!(peer instanceof CMenuItem)) return;

    final CMenuItem cmi = (CMenuItem)peer;
    Image img = null;

    if (i != null) {
        if (i.getIconWidth() > 0 && i.getIconHeight() > 0) {
            img = AquaIcon.getImageForIcon(i);
        }
    }
    cmi.setImage(img);
}
 
Example #20
Source File: ScreenMenuItemCheckbox.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void setIcon(final Icon i) {
    final MenuComponentPeer peer = getPeer();
    if (!(peer instanceof CMenuItem)) return;

    final CMenuItem cmi = (CMenuItem)peer;
    Image img = null;

    if (i != null) {
        if (i.getIconWidth() > 0 && i.getIconHeight() > 0) {
            img = AquaIcon.getImageForIcon(i);
        }
    }
    cmi.setImage(img);
}
 
Example #21
Source File: _AppMenuBarHandler.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
static void installDefaultMenuBar(final JMenuBar menuBar) {
    if (menuBar == null) {
        // intentionally clearing the default menu
        nativeSetDefaultMenuBar(0);
        return;
    }

    final MenuBarUI ui = menuBar.getUI();
    if (!(ui instanceof AquaMenuBarUI)) {
        // Aqua was not installed
        throw new IllegalStateException("Application.setDefaultMenuBar() only works with the Aqua Look and Feel");
    }

    final AquaMenuBarUI aquaUI = (AquaMenuBarUI)ui;
    final ScreenMenuBar screenMenuBar = aquaUI.getScreenMenuBar();
    if (screenMenuBar == null) {
        // Aqua is installed, but we aren't using the screen menu bar
        throw new IllegalStateException("Application.setDefaultMenuBar() only works if apple.laf.useScreenMenuBar=true");
    }

    screenMenuBar.addNotify();
    final MenuComponentPeer peer = screenMenuBar.getPeer();
    if (!(peer instanceof CMenuBar)) {
        // such a thing should not be possible
        throw new IllegalStateException("Unable to determine native menu bar from provided JMenuBar");
    }

    // grab the pointer to the CMenuBar, and retain it in native
    nativeSetDefaultMenuBar(((CMenuBar)peer).getModel());
}
 
Example #22
Source File: ScreenMenuItem.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
static void syncLabelAndKS(MenuItem menuItem, String label, KeyStroke ks) {
    final MenuComponentPeer peer = menuItem.getPeer();
    if (!(peer instanceof CMenuItem)) {
        //Is it possible?
        return;
    }
    final CMenuItem cmi = (CMenuItem) peer;
    if (ks == null) {
        cmi.setLabel(label);
    } else {
        cmi.setLabel(label, ks.getKeyChar(), ks.getKeyCode(),
                     ks.getModifiers());
    }
}
 
Example #23
Source File: ScreenMenu.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void setIcon(final Icon i) {
    final MenuComponentPeer peer = getPeer();
    if (!(peer instanceof CMenuItem)) return;

    final CMenuItem cmi = (CMenuItem)peer;
    Image img = null;

    if (i != null) {
        if (i.getIconWidth() > 0 && i.getIconHeight() > 0) {
            img = AquaIcon.getImageForIcon(i);
        }
    }
    cmi.setImage(img);
}
 
Example #24
Source File: MenuComponent.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * Removes the menu component's peer.  The peer allows us to modify the
 * appearance of the menu component without changing the functionality of
 * the menu component.
 */
public void removeNotify() {
    synchronized (getTreeLock()) {
        MenuComponentPeer p = this.peer;
        if (p != null) {
            Toolkit.getEventQueue().removeSourceEvents(this, true);
            this.peer = null;
            p.dispose();
        }
    }
}
 
Example #25
Source File: ScreenMenu.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void setToolTipText(final String text) {
    final MenuComponentPeer peer = getPeer();
    if (!(peer instanceof CMenuItem)) return;

    final CMenuItem cmi = (CMenuItem)peer;
    cmi.setToolTipText(text);
}
 
Example #26
Source File: ScreenMenuItemCheckbox.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public void setIcon(final Icon i) {
    final MenuComponentPeer peer = getPeer();
    if (!(peer instanceof CMenuItem)) return;

    final CMenuItem cmi = (CMenuItem)peer;
    Image img = null;

    if (i != null) {
        if (i.getIconWidth() > 0 && i.getIconHeight() > 0) {
            img = AquaIcon.getImageForIcon(i);
        }
    }
    cmi.setImage(img);
}
 
Example #27
Source File: ScreenMenu.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void setIcon(final Icon i) {
    final MenuComponentPeer peer = getPeer();
    if (!(peer instanceof CMenuItem)) return;

    final CMenuItem cmi = (CMenuItem)peer;
    Image img = null;

    if (i != null) {
        if (i.getIconWidth() > 0 && i.getIconHeight() > 0) {
            img = AquaIcon.getImageForIcon(i);
        }
    }
    cmi.setImage(img);
}
 
Example #28
Source File: MenuComponent.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Removes the menu component's peer.  The peer allows us to modify the
 * appearance of the menu component without changing the functionality of
 * the menu component.
 */
public void removeNotify() {
    synchronized (getTreeLock()) {
        MenuComponentPeer p = this.peer;
        if (p != null) {
            Toolkit.getEventQueue().removeSourceEvents(this, true);
            this.peer = null;
            p.dispose();
        }
    }
}
 
Example #29
Source File: ScreenMenu.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void setIcon(final Icon i) {
    final MenuComponentPeer peer = getPeer();
    if (!(peer instanceof CMenuItem)) return;

    final CMenuItem cmi = (CMenuItem)peer;
    Image img = null;

    if (i != null) {
        if (i.getIconWidth() > 0 && i.getIconHeight() > 0) {
            img = AquaIcon.getImageForIcon(i);
        }
    }
    cmi.setImage(img);
}
 
Example #30
Source File: MenuComponent.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Removes the menu component's peer.  The peer allows us to modify the
 * appearance of the menu component without changing the functionality of
 * the menu component.
 */
public void removeNotify() {
    synchronized (getTreeLock()) {
        MenuComponentPeer p = this.peer;
        if (p != null) {
            Toolkit.getEventQueue().removeSourceEvents(this, true);
            this.peer = null;
            p.dispose();
        }
    }
}