Java 类java.awt.peer.MenuComponentPeer 实例源码

项目:OpenJSharp    文件:MenuComponent.java   
/**
 * 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();
        }
    }
}
项目:OpenJSharp    文件:_AppMenuBarHandler.java   
@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());
}
项目:OpenJSharp    文件:ScreenMenu.java   
@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);
            }
        }
    }
}
项目:OpenJSharp    文件:ScreenMenu.java   
@Override
public void setToolTipText(final String text) {
    final MenuComponentPeer peer = getPeer();
    if (!(peer instanceof CMenuItem)) return;

    final CMenuItem cmi = (CMenuItem)peer;
    cmi.setToolTipText(text);
}
项目:OpenJSharp    文件:ScreenMenu.java   
@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);
}
项目:OpenJSharp    文件:ScreenMenuItem.java   
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());
    }
}
项目:OpenJSharp    文件:ScreenMenuItem.java   
public void setToolTipText(final String text) {
    final MenuComponentPeer peer = getPeer();
    if (!(peer instanceof CMenuItem)) return;

    final CMenuItem cmi = (CMenuItem)peer;
    cmi.setToolTipText(text);
}
项目:OpenJSharp    文件:ScreenMenuItem.java   
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);
}
项目:OpenJSharp    文件:ScreenMenuItemCheckbox.java   
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);
}
项目:jdk8u-jdk    文件:MenuComponent.java   
/**
 * 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();
        }
    }
}
项目:jdk8u-jdk    文件:_AppMenuBarHandler.java   
@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
    ((CMenuBar) peer).execute(_AppMenuBarHandler::nativeSetDefaultMenuBar);
}
项目:jdk8u-jdk    文件:ScreenMenu.java   
@Override
public void addNotify() {
    synchronized (getTreeLock()) {
        super.addNotify();
        if (fModelPtr == 0) {
            fInvoker.getPopupMenu().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);
            }
        }
    }
}
项目:jdk8u-jdk    文件:ScreenMenu.java   
@Override
public void setToolTipText(final String text) {
    final MenuComponentPeer peer = getPeer();
    if (!(peer instanceof CMenuItem)) return;

    final CMenuItem cmi = (CMenuItem)peer;
    cmi.setToolTipText(text);
}
项目:jdk8u-jdk    文件:ScreenMenu.java   
@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);
}
项目:jdk8u-jdk    文件:ScreenMenuItem.java   
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());
    }
}
项目:jdk8u-jdk    文件:ScreenMenuItem.java   
public void setToolTipText(final String text) {
    final MenuComponentPeer peer = getPeer();
    if (!(peer instanceof CMenuItem)) return;

    final CMenuItem cmi = (CMenuItem)peer;
    cmi.setToolTipText(text);
}
项目:jdk8u-jdk    文件:ScreenMenuItem.java   
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);
}
项目:jdk8u-jdk    文件:ScreenMenuItemCheckbox.java   
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);
}
项目:openjdk-jdk10    文件:MenuComponent.java   
/**
 * 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();
        }
    }
}
项目:openjdk9    文件:MenuComponent.java   
/**
 * 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();
        }
    }
}
项目:Java8CN    文件:MenuComponent.java   
/**
 * 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();
        }
    }
}
项目:jdk8u_jdk    文件:MenuComponent.java   
/**
 * 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();
        }
    }
}
项目:jdk8u_jdk    文件:_AppMenuBarHandler.java   
@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
    ((CMenuBar) peer).execute(_AppMenuBarHandler::nativeSetDefaultMenuBar);
}
项目:jdk8u_jdk    文件:ScreenMenu.java   
@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);
            }
        }
    }
}
项目:jdk8u_jdk    文件:ScreenMenu.java   
@Override
public void setToolTipText(final String text) {
    final MenuComponentPeer peer = getPeer();
    if (!(peer instanceof CMenuItem)) return;

    final CMenuItem cmi = (CMenuItem)peer;
    cmi.setToolTipText(text);
}
项目:jdk8u_jdk    文件:ScreenMenu.java   
@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);
}
项目:jdk8u_jdk    文件:ScreenMenuItem.java   
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());
    }
}
项目:jdk8u_jdk    文件:ScreenMenuItem.java   
public void setToolTipText(final String text) {
    final MenuComponentPeer peer = getPeer();
    if (!(peer instanceof CMenuItem)) return;

    final CMenuItem cmi = (CMenuItem)peer;
    cmi.setToolTipText(text);
}
项目:jdk8u_jdk    文件:ScreenMenuItem.java   
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);
}
项目:jdk8u_jdk    文件:ScreenMenuItemCheckbox.java   
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);
}
项目:lookaside_java-1.8.0-openjdk    文件:MenuComponent.java   
/**
 * 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();
        }
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:_AppMenuBarHandler.java   
@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
    ((CMenuBar) peer).execute(_AppMenuBarHandler::nativeSetDefaultMenuBar);
}
项目:lookaside_java-1.8.0-openjdk    文件:ScreenMenu.java   
@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);
            }
        }
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:ScreenMenu.java   
@Override
public void setToolTipText(final String text) {
    final MenuComponentPeer peer = getPeer();
    if (!(peer instanceof CMenuItem)) return;

    final CMenuItem cmi = (CMenuItem)peer;
    cmi.setToolTipText(text);
}
项目:lookaside_java-1.8.0-openjdk    文件:ScreenMenu.java   
@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);
}
项目:lookaside_java-1.8.0-openjdk    文件:ScreenMenuItem.java   
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());
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:ScreenMenuItem.java   
public void setToolTipText(final String text) {
    final MenuComponentPeer peer = getPeer();
    if (!(peer instanceof CMenuItem)) return;

    final CMenuItem cmi = (CMenuItem)peer;
    cmi.setToolTipText(text);
}
项目:lookaside_java-1.8.0-openjdk    文件:ScreenMenuItem.java   
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);
}
项目:lookaside_java-1.8.0-openjdk    文件:ScreenMenuItemCheckbox.java   
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);
}
项目:VarJ    文件:MenuComponent.java   
/**
    * 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 = (MenuComponentPeer)this.peer;
    if (p != null) {
        Toolkit.getEventQueue().removeSourceEvents(this, true);
    this.peer = null;
    p.dispose();
    }
}
   }