java类java.awt.TrayIcon的实例源码

Program.java 文件源码 项目:litiengine 阅读 20 收藏 0 点赞 0 评论 0
private static void initSystemTray() {
  // add system tray icon with popup menu
  if (SystemTray.isSupported()) {
    SystemTray tray = SystemTray.getSystemTray();
    PopupMenu menu = new PopupMenu();
    MenuItem exitItem = new MenuItem(Resources.get("menu_exit"));
    exitItem.addActionListener(a -> Game.terminate());
    menu.add(exitItem);

    trayIcon = new TrayIcon(RenderEngine.getImage("pixel-icon-utility.png"), Game.getInfo().toString(), menu);
    trayIcon.setImageAutoSize(true);
    try {
      tray.add(trayIcon);
    } catch (AWTException e) {
      log.log(Level.SEVERE, e.getLocalizedMessage(), e);
    }
  }
}
AgentGUITrayIcon.java 文件源码 项目:AgentWorkbench 阅读 18 收藏 0 点赞 0 评论 0
/**
 * Starts the TrayIcon, if this is supported. If not, it should start a
 * simple JDialog, doing the same as independent Window.
 */
private void initialize() {

    switch (this.getTrayIconUsage()) {
    case TrayIcon:
        try {
            // --- System-Tray is supported ---------------------
            this.getSystemTray().add(this.getTrayIcon(true));

        } catch (AWTException e) {
            System.err.println("TrayIcon supported, but could not be added. => Use TrayDialog instead !");
            this.getAgentGUITrayDialog(true).setVisible(true);          
        }
        break;

    case TrayDialog:
        this.getAgentGUITrayDialog(true).setVisible(true);
        break;

    default:
        break;
    }

    // --- Refresh tray icon ------------------------------------
    this.getAgentGUITrayPopUp().refreshView();
}
Dropzone.java 文件源码 项目:dracoon-dropzone 阅读 25 收藏 0 点赞 0 评论 0
/**
 * Init Swing UI
 */
private void initUI() {
    URL url = null;
    if (ConfigIO.getInstance().isUseDarkIcon()) {
        url = Dropzone.class.getResource("/images/sds_logo_dark.png");
    } else {
        url = Dropzone.class.getResource("/images/sds_logo_light.png");

    }
    if (Util.getOSType() == OSType.MACOS) {

    }

    trayIcon = new TrayIcon(Toolkit.getDefaultToolkit().getImage(url), I18n.get("tray.appname"),
            new TrayPopupMenu());
    trayIcon.setImageAutoSize(true);

    final SystemTray tray = SystemTray.getSystemTray();
    try {
        tray.add(trayIcon);
    } catch (AWTException e) {
        LOG.error("TrayIcon could not be added.");
        System.exit(1);
    }
}
WTrayIconPeer.java 文件源码 项目:OpenJSharp 阅读 33 收藏 0 点赞 0 评论 0
@Override
public synchronized void showPopupMenu(final int x, final int y) {
    if (isDisposed())
        return;

    SunToolkit.executeOnEventHandlerThread(target, new Runnable() {
            @Override
            public void run() {
                PopupMenu newPopup = ((TrayIcon)target).getPopupMenu();
                if (popup != newPopup) {
                    if (popup != null) {
                        popupParent.remove(popup);
                    }
                    if (newPopup != null) {
                        popupParent.add(newPopup);
                    }
                    popup = newPopup;
                }
                if (popup != null) {
                    ((WPopupMenuPeer)popup.getPeer()).show(popupParent, new Point(x, y));
                }
            }
        });
}
WTrayIconPeer.java 文件源码 项目:OpenJSharp 阅读 26 收藏 0 点赞 0 评论 0
synchronized void updateNativeImage(Image image) {
    if (isDisposed())
        return;

    boolean autosize = ((TrayIcon)target).isImageAutoSize();

    BufferedImage bufImage = new BufferedImage(TRAY_ICON_WIDTH, TRAY_ICON_HEIGHT,
                                               BufferedImage.TYPE_INT_ARGB);
    Graphics2D gr = bufImage.createGraphics();
    if (gr != null) {
        try {
            gr.setPaintMode();

            gr.drawImage(image, 0, 0, (autosize ? TRAY_ICON_WIDTH : image.getWidth(observer)),
                         (autosize ? TRAY_ICON_HEIGHT : image.getHeight(observer)), observer);

            createNativeImage(bufImage);

            updateNativeIcon(!firstUpdate);
            if (firstUpdate) firstUpdate = false;

        } finally {
            gr.dispose();
        }
    }
}
WTrayIconPeer.java 文件源码 项目:jdk8u-jdk 阅读 23 收藏 0 点赞 0 评论 0
@Override
public synchronized void showPopupMenu(final int x, final int y) {
    if (isDisposed())
        return;

    SunToolkit.executeOnEventHandlerThread(target, new Runnable() {
            @Override
            public void run() {
                PopupMenu newPopup = ((TrayIcon)target).getPopupMenu();
                if (popup != newPopup) {
                    if (popup != null) {
                        popupParent.remove(popup);
                    }
                    if (newPopup != null) {
                        popupParent.add(newPopup);
                    }
                    popup = newPopup;
                }
                if (popup != null) {
                    ((WPopupMenuPeer)popup.getPeer()).show(popupParent, new Point(x, y));
                }
            }
        });
}
WTrayIconPeer.java 文件源码 项目:jdk8u-jdk 阅读 28 收藏 0 点赞 0 评论 0
synchronized void updateNativeImage(Image image) {
    if (isDisposed())
        return;

    boolean autosize = ((TrayIcon)target).isImageAutoSize();

    BufferedImage bufImage = new BufferedImage(TRAY_ICON_WIDTH, TRAY_ICON_HEIGHT,
                                               BufferedImage.TYPE_INT_ARGB);
    Graphics2D gr = bufImage.createGraphics();
    if (gr != null) {
        try {
            gr.setPaintMode();

            gr.drawImage(image, 0, 0, (autosize ? TRAY_ICON_WIDTH : image.getWidth(observer)),
                         (autosize ? TRAY_ICON_HEIGHT : image.getHeight(observer)), observer);

            createNativeImage(bufImage);

            updateNativeIcon(!firstUpdate);
            if (firstUpdate) firstUpdate = false;

        } finally {
            gr.dispose();
        }
    }
}
WTrayIconPeer.java 文件源码 项目:openjdk-jdk10 阅读 24 收藏 0 点赞 0 评论 0
@Override
public synchronized void showPopupMenu(final int x, final int y) {
    if (isDisposed())
        return;

    SunToolkit.executeOnEventHandlerThread(target, () -> {
        PopupMenu newPopup = ((TrayIcon)target).getPopupMenu();
        if (popup != newPopup) {
            if (popup != null) {
                popupParent.remove(popup);
            }
            if (newPopup != null) {
                popupParent.add(newPopup);
            }
            popup = newPopup;
        }
        if (popup != null) {
            WPopupMenuPeer peer = AWTAccessor.getMenuComponentAccessor()
                                             .getPeer(popup);
            peer.show(popupParent, new Point(x, y));
        }
    });
}
UpdatePopupMenu.java 文件源码 项目:openjdk-jdk10 阅读 22 收藏 0 点赞 0 评论 0
private PopupMenu createPopupMenu(final TrayIcon trayIcon,
        final int menuCount) {

    final PopupMenu trayIconPopupMenu = new PopupMenu();

    for (int i = 1; i <= menuCount; ++i) {
        final MenuItem popupMenuItem = new MenuItem("MenuItem_" + i);

        popupMenuItem.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(final ActionEvent ae) {
                trayIcon.setPopupMenu(createPopupMenu(trayIcon,
                        menuCount + 1));
            }
        });

        trayIconPopupMenu.add(popupMenuItem);
    }

    return trayIconPopupMenu;
}
ActionEventTest.java 文件源码 项目:openjdk-jdk10 阅读 21 收藏 0 点赞 0 评论 0
private void initializeGUI() {

        icon = new TrayIcon(
            new BufferedImage(20, 20, BufferedImage.TYPE_INT_RGB), "ti");
        icon.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent ae) {
                actionPerformed = true;
                int md = ae.getModifiers();
                int expectedMask = ActionEvent.ALT_MASK | ActionEvent.CTRL_MASK
                        | ActionEvent.SHIFT_MASK;

                if ((md & expectedMask) != expectedMask) {
                    clear();
                    throw new RuntimeException("Action Event modifiers are not"
                        + " set correctly.");
                }
            }
        });

        try {
            SystemTray.getSystemTray().add(icon);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
QTray.java 文件源码 项目:sbc-qsystem 阅读 16 收藏 0 点赞 0 评论 0
/**
 * Показать сообщение в системном трее
 *
 * @param message текст сообщения
 * @param type тип сообщения
 */
synchronized public void showMessageTray(String caption, String message, MessageType type) {
    TrayIcon.MessageType t = TrayIcon.MessageType.NONE;
    switch (type) {
        case ERROR: {
            t = TrayIcon.MessageType.ERROR;
            break;
        }
        case WARNING: {
            t = TrayIcon.MessageType.WARNING;
            break;
        }
        case INFO: {
            t = TrayIcon.MessageType.INFO;
            break;
        }
    }
    trayIcon.displayMessage(caption, message, t);
}
WTrayIconPeer.java 文件源码 项目:openjdk9 阅读 24 收藏 0 点赞 0 评论 0
@Override
public synchronized void showPopupMenu(final int x, final int y) {
    if (isDisposed())
        return;

    SunToolkit.executeOnEventHandlerThread(target, () -> {
        PopupMenu newPopup = ((TrayIcon)target).getPopupMenu();
        if (popup != newPopup) {
            if (popup != null) {
                popupParent.remove(popup);
            }
            if (newPopup != null) {
                popupParent.add(newPopup);
            }
            popup = newPopup;
        }
        if (popup != null) {
            WPopupMenuPeer peer = AWTAccessor.getMenuComponentAccessor()
                                             .getPeer(popup);
            peer.show(popupParent, new Point(x, y));
        }
    });
}
WTrayIconPeer.java 文件源码 项目:openjdk9 阅读 42 收藏 0 点赞 0 评论 0
synchronized void updateNativeImage(Image image) {
    if (isDisposed())
        return;

    boolean autosize = ((TrayIcon)target).isImageAutoSize();

    BufferedImage bufImage = new BufferedImage(TRAY_ICON_WIDTH, TRAY_ICON_HEIGHT,
                                               BufferedImage.TYPE_INT_ARGB);
    Graphics2D gr = bufImage.createGraphics();
    if (gr != null) {
        try {
            gr.setPaintMode();

            gr.drawImage(image, 0, 0, (autosize ? TRAY_ICON_WIDTH : image.getWidth(observer)),
                         (autosize ? TRAY_ICON_HEIGHT : image.getHeight(observer)), observer);

            createNativeImage(bufImage);

            updateNativeIcon(!firstUpdate);
            if (firstUpdate) firstUpdate = false;

        } finally {
            gr.dispose();
        }
    }
}
UpdatePopupMenu.java 文件源码 项目:openjdk9 阅读 19 收藏 0 点赞 0 评论 0
private PopupMenu createPopupMenu(final TrayIcon trayIcon,
        final int menuCount) {

    final PopupMenu trayIconPopupMenu = new PopupMenu();

    for (int i = 1; i <= menuCount; ++i) {
        final MenuItem popupMenuItem = new MenuItem("MenuItem_" + i);

        popupMenuItem.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(final ActionEvent ae) {
                trayIcon.setPopupMenu(createPopupMenu(trayIcon,
                        menuCount + 1));
            }
        });

        trayIconPopupMenu.add(popupMenuItem);
    }

    return trayIconPopupMenu;
}
ActionEventTest.java 文件源码 项目:openjdk9 阅读 23 收藏 0 点赞 0 评论 0
private void initializeGUI() {

        icon = new TrayIcon(
            new BufferedImage(20, 20, BufferedImage.TYPE_INT_RGB), "ti");
        icon.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent ae) {
                actionPerformed = true;
                int md = ae.getModifiers();
                int expectedMask = ActionEvent.ALT_MASK | ActionEvent.CTRL_MASK
                        | ActionEvent.SHIFT_MASK;

                if ((md & expectedMask) != expectedMask) {
                    clear();
                    throw new RuntimeException("Action Event modifiers are not"
                        + " set correctly.");
                }
            }
        });

        try {
            SystemTray.getSystemTray().add(icon);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
HelloWorld.java 文件源码 项目:yajsw 阅读 29 收藏 0 点赞 0 评论 0
private static void startTray()
{
    SystemTray tray = SystemTray.getSystemTray();
    int w = 80;
    int[] pix = new int[w * w];
    for (int i = 0; i < w * w; i++)
        pix[i] = (int) (Math.random() * 255);
    ImageProducer producer = new MemoryImageSource(w, w, pix, 0, w);
    Image image = Toolkit.getDefaultToolkit().createImage(producer);
    TrayIcon trayIcon = new TrayIcon(image);
    trayIcon.setImageAutoSize(true);
    startWindow();
    try
    {
        tray.add(trayIcon);
        System.out.println("installed tray");
    }
    catch (AWTException e)
    {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
TimeTray.java 文件源码 项目:timetray 阅读 18 收藏 0 点赞 0 评论 0
/**
 * TimeTray Constructor
 */
public TimeTray() {
    // retrieve iconSize of SystemTray
    SystemTray systemTray = SystemTray.getSystemTray();
    iconSize = systemTray.getTrayIconSize();

    // set presets
    presets = new Presets(iconSize.height);

    calendar = Calendar.getInstance();

    // create TrayIcon according to iconSize
    trayIcon = new TrayIcon(getTrayImage(), "TimeTray", menu);
    try {
        systemTray.add(trayIcon);
    } catch (AWTException ex) {
        ex.printStackTrace();
    }

    // run thread and set timer tooltip to update every second
    run();

    Timer timer = new Timer();
    timer.schedule(this, 1000, 1000);
}
WTrayIconPeer.java 文件源码 项目:jdk8u_jdk 阅读 21 收藏 0 点赞 0 评论 0
@Override
public synchronized void showPopupMenu(final int x, final int y) {
    if (isDisposed())
        return;

    SunToolkit.executeOnEventHandlerThread(target, new Runnable() {
            @Override
            public void run() {
                PopupMenu newPopup = ((TrayIcon)target).getPopupMenu();
                if (popup != newPopup) {
                    if (popup != null) {
                        popupParent.remove(popup);
                    }
                    if (newPopup != null) {
                        popupParent.add(newPopup);
                    }
                    popup = newPopup;
                }
                if (popup != null) {
                    ((WPopupMenuPeer)popup.getPeer()).show(popupParent, new Point(x, y));
                }
            }
        });
}
WTrayIconPeer.java 文件源码 项目:jdk8u_jdk 阅读 23 收藏 0 点赞 0 评论 0
synchronized void updateNativeImage(Image image) {
    if (isDisposed())
        return;

    boolean autosize = ((TrayIcon)target).isImageAutoSize();

    BufferedImage bufImage = new BufferedImage(TRAY_ICON_WIDTH, TRAY_ICON_HEIGHT,
                                               BufferedImage.TYPE_INT_ARGB);
    Graphics2D gr = bufImage.createGraphics();
    if (gr != null) {
        try {
            gr.setPaintMode();

            gr.drawImage(image, 0, 0, (autosize ? TRAY_ICON_WIDTH : image.getWidth(observer)),
                         (autosize ? TRAY_ICON_HEIGHT : image.getHeight(observer)), observer);

            createNativeImage(bufImage);

            updateNativeIcon(!firstUpdate);
            if (firstUpdate) firstUpdate = false;

        } finally {
            gr.dispose();
        }
    }
}
Notifier.java 文件源码 项目:runelite 阅读 31 收藏 0 点赞 0 评论 0
private void sendNotification(
    final String title,
    final String message,
    final TrayIcon.MessageType type,
    final String subtitle)
{
    final String escapedTitle = SHELL_ESCAPE.escape(title);
    final String escapedMessage = SHELL_ESCAPE.escape(message);
    final String escapedSubtitle = subtitle != null ? SHELL_ESCAPE.escape(subtitle) : null;

    switch (DETECTED_OS)
    {
        case Linux:
            sendLinuxNotification(escapedTitle, escapedMessage, type);
            break;
        case MacOS:
            sendMacNotification(escapedTitle, escapedMessage, escapedSubtitle);
            break;
        default:
            sendTrayNotification(title, message, type);
    }
}
WTrayIconPeer.java 文件源码 项目:lookaside_java-1.8.0-openjdk 阅读 25 收藏 0 点赞 0 评论 0
@Override
public synchronized void showPopupMenu(final int x, final int y) {
    if (isDisposed())
        return;

    SunToolkit.executeOnEventHandlerThread(target, new Runnable() {
            @Override
            public void run() {
                PopupMenu newPopup = ((TrayIcon)target).getPopupMenu();
                if (popup != newPopup) {
                    if (popup != null) {
                        popupParent.remove(popup);
                    }
                    if (newPopup != null) {
                        popupParent.add(newPopup);
                    }
                    popup = newPopup;
                }
                if (popup != null) {
                    ((WPopupMenuPeer)popup.getPeer()).show(popupParent, new Point(x, y));
                }
            }
        });
}
WTrayIconPeer.java 文件源码 项目:lookaside_java-1.8.0-openjdk 阅读 25 收藏 0 点赞 0 评论 0
synchronized void updateNativeImage(Image image) {
    if (isDisposed())
        return;

    boolean autosize = ((TrayIcon)target).isImageAutoSize();

    BufferedImage bufImage = new BufferedImage(TRAY_ICON_WIDTH, TRAY_ICON_HEIGHT,
                                               BufferedImage.TYPE_INT_ARGB);
    Graphics2D gr = bufImage.createGraphics();
    if (gr != null) {
        try {
            gr.setPaintMode();

            gr.drawImage(image, 0, 0, (autosize ? TRAY_ICON_WIDTH : image.getWidth(observer)),
                         (autosize ? TRAY_ICON_HEIGHT : image.getHeight(observer)), observer);

            createNativeImage(bufImage);

            updateNativeIcon(!firstUpdate);
            if (firstUpdate) firstUpdate = false;

        } finally {
            gr.dispose();
        }
    }
}
duckdns.java 文件源码 项目:DuckDNSClient 阅读 17 收藏 0 点赞 0 评论 0
private void startProcess() {

Thread thread = new Thread(new Runnable() {

 @Override public void run() {
 Preferences prefs = Preferences.userNodeForPackage(duckdns.class);

 // first start message (on empty settings)
 if ((prefs.get("domain", "").length() < 1) || (prefs.get("token", "").length() < 1)) {
 processTrayIcon.displayMessage(DuckDNSVersion, "Right click on the tray icon to change the settings!", TrayIcon.MessageType.INFO);
 }

 Timer timer = new Timer("Repeater");
 MyTask t = new MyTask();
 timer.schedule(t, 0, 1000);

 timercount = (Integer.parseInt(prefs.get("refresh", "5")) * 60);

 }
});

thread.start();
}
SmallUI.java 文件源码 项目:deskshare-public 阅读 20 收藏 0 点赞 0 评论 0
private void initTray() {
    final SystemTray systemTray = SystemTray.getSystemTray();
    final TrayIcon trayIcon = new TrayIcon(getImage("icon.gif"), "Deskshare is running");
    trayIcon.setImageAutoSize(true); // Autosize icon base on space
                                     // available on tray
    MouseAdapter mouseAdapter = new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent evt) {
            // This will display small popup message from System Tray
            trayIcon.displayMessage("BigMarker Deskshare", "This is an info message", TrayIcon.MessageType.INFO);
            if (!app.isVisible()) {
                app.setVisible(true);
            }
        }
    };
    trayIcon.addMouseListener(mouseAdapter);
    try {
        systemTray.add(trayIcon);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
DebugUI.java 文件源码 项目:deskshare-public 阅读 20 收藏 0 点赞 0 评论 0
private void initTray() {
    final SystemTray systemTray = SystemTray.getSystemTray();
    final TrayIcon trayIcon = new TrayIcon(getImage("icon.gif"), "Deskshare is running");
    trayIcon.setImageAutoSize(true); // Autosize icon base on space available on tray
    MouseAdapter mouseAdapter = new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent evt) {
            System.out.println("icon clicked: " + evt.getClickCount());
            // This will display small popup message from System Tray
            trayIcon.displayMessage("BigMarker Deskshare", "This is an info message", TrayIcon.MessageType.INFO);
            if (!app.isVisible()) {
                app.setVisible(true);
            }
        }
    };
    trayIcon.addMouseListener(mouseAdapter);
    try {
        systemTray.add(trayIcon);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Tray.java 文件源码 项目:MIDI-Automator 阅读 19 收藏 0 点赞 0 评论 0
/**
 * Initializes the tray
 */
public void init() {

    if (SystemTray.isSupported()) {

        SystemTray tray = SystemTray.getSystemTray();

        if (tray.getTrayIcons().length == 0) {

            String iconFileName = resources.getImagePath() + File.separator
                    + "MidiAutomatorIcon16.png";
            image = Toolkit.getDefaultToolkit().getImage(iconFileName);
            trayPopupMenu.init();
            trayIcon = new TrayIcon(image, NAME);
            trayIcon.addMouseListener(trayMouseListener);

            try {
                tray.add(trayIcon);
            } catch (AWTException e) {
                log.error("Error on adding tray icon.", e);
            }
        }
    }
}
Tray.java 文件源码 项目:TodoLazyList 阅读 22 收藏 0 点赞 0 评论 0
private void hookTray() {
    if (!SystemTray.isSupported()) {
        System.out.println("SystemTray is not supported");
    } else {
        try {
            Todo.icon = new TrayIcon(ImageIO.read(Todo.class.getResourceAsStream("/todo/res/logoTray.png")), "TODO application",
                    createPopupMenu());
            Todo.icon.addActionListener((ActionEvent e) -> {
                Platform.runLater(() -> {
                    stage.setIconified(false);
                });
                //some popup test
            });
            SystemTray.getSystemTray().add(Todo.icon);
            //Thread.sleep(3000);
            Todo.icon.displayMessage("TODO", "Listener enabled",
                    TrayIcon.MessageType.INFO);

        } catch (AWTException | IOException ex) {
            ex.printStackTrace();
        }

    }
}
WTrayIconPeer.java 文件源码 项目:infobip-open-jdk-8 阅读 22 收藏 0 点赞 0 评论 0
@Override
public synchronized void showPopupMenu(final int x, final int y) {
    if (isDisposed())
        return;

    SunToolkit.executeOnEventHandlerThread(target, new Runnable() {
            @Override
            public void run() {
                PopupMenu newPopup = ((TrayIcon)target).getPopupMenu();
                if (popup != newPopup) {
                    if (popup != null) {
                        popupParent.remove(popup);
                    }
                    if (newPopup != null) {
                        popupParent.add(newPopup);
                    }
                    popup = newPopup;
                }
                if (popup != null) {
                    ((WPopupMenuPeer)popup.getPeer()).show(popupParent, new Point(x, y));
                }
            }
        });
}
WTrayIconPeer.java 文件源码 项目:infobip-open-jdk-8 阅读 28 收藏 0 点赞 0 评论 0
synchronized void updateNativeImage(Image image) {
    if (isDisposed())
        return;

    boolean autosize = ((TrayIcon)target).isImageAutoSize();

    BufferedImage bufImage = new BufferedImage(TRAY_ICON_WIDTH, TRAY_ICON_HEIGHT,
                                               BufferedImage.TYPE_INT_ARGB);
    Graphics2D gr = bufImage.createGraphics();
    if (gr != null) {
        try {
            gr.setPaintMode();

            gr.drawImage(image, 0, 0, (autosize ? TRAY_ICON_WIDTH : image.getWidth(observer)),
                         (autosize ? TRAY_ICON_HEIGHT : image.getHeight(observer)), observer);

            createNativeImage(bufImage);

            updateNativeIcon(!firstUpdate);
            if (firstUpdate) firstUpdate = false;

        } finally {
            gr.dispose();
        }
    }
}
WTrayIconPeer.java 文件源码 项目:jdk8u-dev-jdk 阅读 80 收藏 0 点赞 0 评论 0
@Override
public synchronized void showPopupMenu(final int x, final int y) {
    if (isDisposed())
        return;

    SunToolkit.executeOnEventHandlerThread(target, new Runnable() {
            @Override
            public void run() {
                PopupMenu newPopup = ((TrayIcon)target).getPopupMenu();
                if (popup != newPopup) {
                    if (popup != null) {
                        popupParent.remove(popup);
                    }
                    if (newPopup != null) {
                        popupParent.add(newPopup);
                    }
                    popup = newPopup;
                }
                if (popup != null) {
                    ((WPopupMenuPeer)popup.getPeer()).show(popupParent, new Point(x, y));
                }
            }
        });
}


问题


面经


文章

微信
公众号

扫码关注公众号