java的SystemTray不适用于Gnome 3.14

jig*_*zon 5 java awt gnome-3

我正在尝试在gnome的通知面板上放置一个Java SystemTray图标(我正在使用OpenSuse 13.2,它使用gnome 3.14).

它不起作用,虽然SystemTray.isSupported()返回"true".我没有在屏幕上看到任何图标.我期待它出现在OpenSuse的通知区旁边.

这是主要的代码:

   public static void main(String[] args) {
        //checking for support
        if (!SystemTray.isSupported()) {
            System.out.println("System tray is not supported !!! ");
            return;
        }
        SystemTray systemTray = SystemTray.getSystemTray();
        Image image = Toolkit.getDefaultToolkit().getImage("icon.ico");

        //popupmenu
        PopupMenu trayPopupMenu = new PopupMenu();

        //1t menuitem for popupmenu
        MenuItem action = new MenuItem("Action");
        action.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                JOptionPane.showMessageDialog(null, "Action Clicked");
            }
        });
        trayPopupMenu.add(action);

        //2nd menuitem of popupmenu
        MenuItem close = new MenuItem("Close");
        close.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                System.exit(0);
            }
        });
        trayPopupMenu.add(close);

        //setting tray icon
        TrayIcon trayIcon = new TrayIcon(image, "SystemTray Demo", trayPopupMenu);
        //adjust to default size as per system recommendation 
        trayIcon.setImageAutoSize(true);

        try {
            systemTray.add(trayIcon);
        } catch (AWTException awtException) {
            awtException.printStackTrace();
        }
        System.out.println("end of main");

    }//end of main
Run Code Online (Sandbox Code Playgroud)