Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/357.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
java';s SystemTray不适用于Gnome 3.14_Java_Awt_Gnome 3 - Fatal编程技术网

java';s SystemTray不适用于Gnome 3.14

java';s SystemTray不适用于Gnome 3.14,java,awt,gnome-3,Java,Awt,Gnome 3,我试图在gnome的通知面板上放置一个JavaSystemTray图标(我使用的是OpenSUSE13.2,它使用的是GNOME3.14) 虽然SystemTray.isSupported()返回“true”,但它不起作用。我在屏幕上没有看到任何图标。我希望它出现在OpenSuse的通知区域旁边 这是主机的代码: public static void main(String[] args) { //checking for support if (!Syst

我试图在gnome的通知面板上放置一个JavaSystemTray图标(我使用的是OpenSUSE13.2,它使用的是GNOME3.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

你能发布代码吗?我已经编辑了问题并添加了代码