简体   繁体   English

如何从系统托盘打开和应用?

[英]how to open and application from system tray?

how to send java application in system tray by close button and restore by click on system tray icon?. 如何通过关闭按钮在系统托盘中发送Java应用程序并通过单击系统托盘图标进行还原?

i have try follow to hide but now how i can get back it by click on system tray? 我已经尝试按照隐藏的方法进行操作,但是现在我该如何通过单击系统托盘来找回它?

 getFrmTaskList().setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);

how it is possible can any one give me proper suggestion have already tried all other way by searching in search box 任何人怎么可能给我适当的建议,已经通过在搜索框中进行搜索以其他方式尝试过

    This is example code you can create appropriate listener and make it working
    //Check the SystemTray is supported
    if (!SystemTray.isSupported()) {
        System.out.println("SystemTray is not supported");
        return;
    }
    final PopupMenu popup = new PopupMenu();
    final TrayIcon trayIcon =
            new TrayIcon(createImage("images/bulb.gif", "tray icon"));
    final SystemTray tray = SystemTray.getSystemTray();

    // Create a pop-up menu components
    MenuItem aboutItem = new MenuItem("About");
    CheckboxMenuItem cb1 = new CheckboxMenuItem("Set auto size");
    CheckboxMenuItem cb2 = new CheckboxMenuItem("Set tooltip");
    Menu displayMenu = new Menu("Display");
    MenuItem errorItem = new MenuItem("Error");
    MenuItem warningItem = new MenuItem("Warning");
    MenuItem infoItem = new MenuItem("Info");
    MenuItem noneItem = new MenuItem("None");
    MenuItem exitItem = new MenuItem("Exit");

    //Add components to pop-up menu
    popup.add(aboutItem);
    popup.addSeparator();
    popup.add(cb1);
    popup.add(cb2);
    popup.addSeparator();
    popup.add(displayMenu);
    displayMenu.add(errorItem);
    displayMenu.add(warningItem);
    displayMenu.add(infoItem);
    displayMenu.add(noneItem);
    popup.add(exitItem);

    trayIcon.setPopupMenu(popup);

    try {
        tray.add(trayIcon);
    } catch (AWTException e) {
        System.out.println("TrayIcon could not be added.");
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM