Results 1 to 4 of 4

Thread: [RESOLVED] Windows Linux conflict - TrayIcon image not display in Linux

  1. #1

    Thread Starter
    PowerPoster eranga262154's Avatar
    Join Date
    Jun 2006
    Posts
    2,201

    Resolved [RESOLVED] Windows Linux conflict - TrayIcon image not display in Linux

    Hi all,

    I have create a TrayIcon and then add image and a pop-up menu into it as follows.

    Code:
    public void trayIconEventHandling()
        {
            TrayIcon trayIcon;
     
            if (SystemTray.isSupported()){
                SystemTray tray = SystemTray.getSystemTray();
                
             // I have to use this ActionEvent to exit the dialog as well
             // Exit from the complete application
                ActionListener exitListener = new ActionListener(){
                    public void actionPerformed(ActionEvent e){
                        System.out.println("Exiting...");
                        System.exit(0);
                    }
                };
                
            // Open the dialog in Actionevent
                ActionListener openDialogListner = new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        System.out.println("Open another Dialog here.");
                        new AboutWindow().setVisible(true);
                    }
                };
                
            // Tray icon menu implimenting goes here
                PopupMenu popup = new PopupMenu();
                MenuItem defaultItem = new MenuItem("Exit");
                MenuItem openDlgItem = new MenuItem("About");
                MenuItem extartItem = new MenuItem("Others...");
                
                openDlgItem.setEnabled(false);
                
                defaultItem.addActionListener(exitListener);
                openDlgItem.addActionListener(openDialogListner);
                
                popup.add(defaultItem);
                popup.add(openDlgItem);
                popup.addSeparator();
                popup.add(extartItem);
     
                Image image = Toolkit.getDefaultToolkit().getImage("mytrayicon/RADAR.gif");
                trayIcon = new TrayIcon(image, "Pop-up", popup);
     
                ActionListener actionListener = new ActionListener(){
                    public void actionPerformed(ActionEvent e){    
                        System.out.println("Main Dialog!");
     
                    // Try to simply call the GUI here
                        mainWnd.setVisible(true);
                    }
                };
                trayIcon.setImageAutoSize(true);
                trayIcon.addActionListener(actionListener);
                trayIcon.addMouseListener(mouseListener);
     
                try
                {
                    tray.add(trayIcon);
                } 
                catch (AWTException e) 
                {
                    System.err.println("TrayIcon could not be added.");
                }
            } 
            else{
                System.err.println("System tray is currently not supported.");
            }   
        }
    My code working well on Windows, loaded the image correctly. But in Linux it don't.

    As far as Java documentation explain, I believe my code is correct. Then why this is happened on Linux. Somebody can give me a hint.

    Thanks.
    “victory breeds hatred, the defeated live in pain; happily the peaceful live giving up victory and defeat” - Gautama Buddha

  2. #2
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: Windows Linux conflict - TrayIcon image not display in Linux

    Just tried it on ubuntu and it worked like a charm. I don't know what have you done wrong
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  3. #3

    Thread Starter
    PowerPoster eranga262154's Avatar
    Join Date
    Jun 2006
    Posts
    2,201

    Re: Windows Linux conflict - TrayIcon image not display in Linux

    That's why I really worried. Functionality, pop-up menu items and such things are working fine except the tray-icon image
    “victory breeds hatred, the defeated live in pain; happily the peaceful live giving up victory and defeat” - Gautama Buddha

  4. #4

    Thread Starter
    PowerPoster eranga262154's Avatar
    Join Date
    Jun 2006
    Posts
    2,201

    Re: Windows Linux conflict - TrayIcon image not display in Linux

    Ok, I have solved this question. I change the tray icon image type in to png. It works. But I don't know why is that.
    “victory breeds hatred, the defeated live in pain; happily the peaceful live giving up victory and defeat” - Gautama Buddha

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width