Popup Menu in system tray - Linux OS -- JAVA 1.4.2

Hi,
I have made an app in Linux( centOS 4.6) which need to pop a message up on system tray when a certain number is reached. I know there is the way to do in sdk1.6. The question: Is there any workaround for 1.4.2 because the deployment machine is in 1.4.2 and the customers dont want to switch to 1.6.
Some hints, links or keywords are appreciated.
Thank you

Have a look at JDIC. (Note: I haven't used that yet, and I don't know which jdk it requires.)

Similar Messages

  • System tray functionality in java

    Hi friends,
    I wanted to know which is the best package to use for implementing the system tray functionality in java.
    I read about systray, jtray,trayicon etc. I saw that TrayIcon is included in jdk 1.6. Is there any other included package in swing which will do this?
    i am just a beginner in swing programming.
    Thanks in advance.

    i would say not. as far as i can remember you can't directly set icons on a AWT MenuItem.
    and you shouldn't mix awt and swing components and most of the time can't do it anyway.
    however, if you have your own MenuItem i recon you could overwrite paint and paint the icons,
    i.e. images yourself using graphics2D methods.
    if you want to dig deeper into it, there are some good tutorials on paint:
    [http://java.sun.com/products/jfc/tsc/articles/painting/]
    might be worth, if you really want to have images and icons on your menuitems.
    i have never done this myself for awt components, but it should work.
    just found something interesting though:
    [http://atunes.svn.sourceforge.net/viewvc/atunes/aTunes_HEAD/src/net/sourceforge/atunes/gui/views/controls/JTrayIcon.java?view=markup]
    apparently, using this class, which derives from the normal TrayIcon, you can set a JPopupMenu and therefore use normal swing components.
    i did not try it though, but it looks very promising.
    Edited by: produggt on 20.08.2008 22:08

  • Menu similar system tray but on button

    Hello, Is it possible create a menu similar to the system tray menù but connected to a button or panel ?. Actually i am using MenuBar but but i am not satisfied.

    Perhaps you could benefit from the use of a popup menu (similar to usual context menus of the operating system). The menu you have designed in the menu bar can be prompted to the user with the following lines in a control callback (here while right clicking on the control but you could choose any other event):
        switch (event) {
            case EVENT_RIGHT_CLICK:
                // Context menu
                choice = RunPopupMenu (GetPanelMenuBar (panel), menuID, panel, eventData1, eventData2, 0, 0, 0, 0);
                switch (choice) {
                     // Your code for single cases here
    Proud to use LW/CVI from 3.1 on.
    My contributions to the Developer Zone Community
    If I have helped you, why not giving me a kudos?

  • Getting System tray icons in Java

    I have developed a swing application and want to control the number of instances running of my own Java class. Is there a simple way how I can do the task?
    Also, i am putting my application in the System tray so, can i get a list of icon for all applications in the system tray? (may be i can control multiple instance using this simple technique)

    sandeep_khurana wrote:
    kevinaworkman wrote:
    Didn't you even look at the API?
    http://java.sun.com/javase/6/docs/api/java/awt/SystemTray.html
    actually the problem is that it is giving null because the api says that it will give the details for the icons by
    'this' application. what i want is all the icons, then, i will decide whether to launch or exit in the succeeding instances of my class.Are you saying that you want to see all of the "icons" in the system tray so that you can iterate over them to see if your icon is one of them and - if it is - not launch your application?
    You're not going to want to do it that way. The "how do I ensure that my program launches only once" problem has been discussed on these forums many times.
    Some options include:
    bind a socket to a not-often-used-port such as 9999 or 9998 or something like that. Two sockets cannot bind to the same port, so that would let you know that you're already running.
    Check for the existence of a file. When you launch your application, if the file exists, it's already running. Delete the file when your program terminates. This technique is pretty common on *NIX systems.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How to activate a menuitem on popup menu?

    hello there
    i've made a popup menu with to menu items
    PopupMenu popup = new PopupMenu();         
                 MenuItem defaultItem2 = new MenuItem("Restore");
                  MenuItem defaultItem = new MenuItem("Exit");
                  popup.add(defaultItem2);
                 popup.add(defaultItem);  and i've put the popup menu on a tray
                               class TrayActionListener implements ActionListener {
            public void actionPerformed(ActionEvent e) {
               trayIcon.getPopupMenu();
        };and i want if the user selects the Exit menuitem the program is closed
    and if he chooses restore the frame is restored from the system tray
    how to do these two action?

    thanks dwg but i have a little problem here
    i have 2 classes one for the systemtray and other for actions on it
    each class is independent
          public void setupSystemTray() {
            if (SystemTray.isSupported()) {
                SystemTray tray = SystemTray.getSystemTray();
                Image image = Toolkit.getDefaultToolkit().getImage("D:\\Other\\JAVA\\Icons\\shutdown.png");
                 PopupMenu popup = new PopupMenu();         
                 MenuItem defaultItem2 = new MenuItem("Restore");
                  MenuItem defaultItem = new MenuItem("Exit");
                   defaultItem.addActionListener(this);
                  popup.add(defaultItem2);
                 popup.add(defaultItem);   
                trayIcon = new TrayIcon(image, "JShutdown Timer",popup);
                trayIcon.setImageAutoSize(true);
                trayIcon.addActionListener(new TrayActionListener());
                try {
                    tray.add(trayIcon);
                } catch (AWTException e) {
                    System.err.println("TrayIcon could not be added.");
                                           class TrayActionListener implements ActionListener {
            public void actionPerformed(ActionEvent e) {
               trayIcon.getPopupMenu();
             if(e.getSource()==defaultItem)
                  System.exit(0);
        };and i want if the user chooses the exit menuitem the program exits
    so i write
    if(e.getSource()==defaultItem)
                  System.exit(0);
             }in the second class the IDE didn't recognize the variable defaultItem
    and it gave me error couldn't find simple variable
    how to fix that?

  • Restoring a JFrame from system Tray

    Hi,
    I am writing a small application to see new system tray api in java.
    Currentlty i am facing a problem - My application minimizes to system tray correctly but when i restore it by clicking on to the tray icon it remains in the minimize state but i want it in restore state.
    private void initTrayIcon()
                Image image = Toolkit.getDefaultToolkit().getImage("tray.gif");
                PopupMenu popup = new PopupMenu();
                MenuItem defaultItem = new MenuItem("Exit");
                defaultItem.addActionListener(new ActionListener()
                    public void actionPerformed(ActionEvent e)
                        exitApplication();
                popup.add(defaultItem);
                trayIcon = new TrayIcon(image, "Tray Demo", popup);
                trayIcon.setImageAutoSize(true);
                trayIcon.addMouseListener(new MouseAdapter()
                    public void mouseClicked(MouseEvent e)
                        //System.out.println("Tray Icon - Mouse clicked!");                
                        setVisible(true);
        }Code of constructor
    initTrayIcon()     
         addWindowListener(new WindowAdapter()
                public void windowDeiconified(WindowEvent e)
                        if (SystemTray.isSupported())
                            SystemTray tray = SystemTray.getSystemTray();
                            tray.remove(trayIcon);
                            setVisible(true);
                            requestFocus();
                public void windowIconified(WindowEvent e)
                    try
                        if (SystemTray.isSupported())
                            SystemTray tray = SystemTray.getSystemTray();
                            tray.add(trayIcon);
                            //setExtendedState(ICONIFIED);
                            setVisible(false);
                    catch (AWTException ex)
                        System.err.println("TrayIcon could not be added.");
            });

    Here is complete code for those who are still facing this problem.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class SystemTrayFinalExample extends JFrame
         public SystemTrayFinalExample()
              if(!SystemTray.isSupported())
                   JOptionPane.showMessageDialog(this,"Your system doesn't supports System Tray","ERROR",0);
                   System.exit(0);
              initComponents();
         private void initComponents()
              setTitle("System Tray Demo");
              setSize(300,200);
              popupmenu = new PopupMenu();
              menuitem1 = new MenuItem("Exit");
              menuitem1.addActionListener(new ActionListener()
                   public void actionPerformed(ActionEvent exx)
                        System.exit(0);
              popupmenu.add(menuitem1);
              trayicon = new TrayIcon(Toolkit.getDefaultToolkit().getImage("computer.png"),"System Tray Final Example",popupmenu);
              trayicon.addMouseListener(new MouseAdapter()
                   public void mouseClicked(MouseEvent e)
                                    if(e.getButton() == MouseEvent.BUTTON1)
                                            setVisible(true);
                                            setExtendedState(JFrame.NORMAL);
              addWindowListener(new WindowAdapter()
                   public void windowClosing(WindowEvent e)
                        System.exit(0);
                   public void windowIconified(WindowEvent ex)
                        setVisible(false);
                        try
                             SystemTray.getSystemTray().add(trayicon);
                        catch(AWTException e)
                             e.printStackTrace();
                        trayicon.displayMessage("Message","Click this icon to restore window",TrayIcon.MessageType.INFO);
                   public void windowDeiconified(WindowEvent ex)
                        SystemTray.getSystemTray().remove(trayicon);
         public static void main(String args[])
              new SystemTrayFinalExample().setVisible(true);
         private TrayIcon trayicon;
         private PopupMenu popupmenu;
         private MenuItem menuitem1;
    }

  • How to listen mouse event when drag on popup menu

    hi, all
    Please explain: When the Frame show, click mouse (left/right) on title bar of Frame, the popup menu will be show
    I Expected :
    When drag mouse on this popup menu will System.out.print("Mouse dragging on popup...");
    Thanks many,

    I know this popup is managed by window
    How to I can get mouse action on it ?

  • My system tray is hidden at top of screen

    system tray automatically hidden at top of screen similar to dock hide.  Reappears when cursor is at top of screen, but I do not want this.  How do I undo this?

    You are in full screen mode with the application you are using. Drag curser to top right of screen and you'll see an icon to get out of that mode. Then your menu (not system tray) will be back.

  • How to get system popup menu in java?

    I want to know how to get windows xp or any operating systems default popupmenu in java.
    And i also have problem for using mnemonic for JPopupMenu, it works well when i first press right click of my mouse and use the specified mnemonic for that the action specifed for that is triggered but when is use mnemonic without the using my mouse it doesn't trigger why.

    Please how to get native(e.g windows explorer) popup menu in jfilechooser

  • Java System Tray Menu

    Hi,
    I am able to use a png icon in my system tray element. ( TrayIcon trayIcon =new TrayIcon(createImage("/images/e-vision3.png", "tray icon"));) . Now i need to add icons to some MenuItems. ie, Both menu name and an icon. I had tried a lot to make this working but failed. Please help me on this issue.
    Thankyou.
    Sreejith P.M.

    Hi,
    Thank you for your answer,
    I am not using JMenuItem. in my application i had used awt MenuItem. (ie, used MenuItem aboutItem = new MenuItem("About"); not JMenuItem aboutItem = new JMenuItem("About"); ) We can add trat icon to system tray. when mouse right click the menu and menu items will show. I need to add some icons in the pop up menu items. Can i do this?
    Thankyou,
    Sreejith
    Edited by: user13423634 on Dec 29, 2010 10:34 PM

  • Java System Tray Menu- pop up on left click.

    Hi,
    The system tray menu will normally pop up on mouse right click. I need to make this pop up on mouse left click. Is it possible? I had tried a lot and failed to find a solution. Please help me on this issue.
    Thank You.

    Hi,
    Thank you for your answer,
    I had tried a lot to make pop up the system tray menu on mouse left click. Finally i got a way to do this. My code is,
    MouseListener ml;
            ml = new MouseListener() {
                public void mouseClicked(MouseEvent e) {
                    if (mouseflag == 0) {
                        try {
                            Robot robot = new Robot();
                            // RIGHT CLICK
                            robot.mousePress(InputEvent.BUTTON3_MASK);
                            robot.mouseRelease(InputEvent.BUTTON3_MASK);
                        } catch (Exception exe) {
                            System.out.println("error=" + exe);
                        mouseflag = 1;
                    } else {
                        mouseflag = 0;
            public void mouseEntered(MouseEvent e) {
              System.out.println("Tray icon: Mouse entered");
            public void mouseExited(MouseEvent e) {
              System.out.println("Tray icon: Mouse exited");
            public void mousePressed(MouseEvent e) {
              System.out.println("Tray icon: Mouse pressed");
            public void mouseReleased(MouseEvent e) {
              System.out.println("Tray icon: Mouse released");
          };here i had created a mouse right click using code (robot class) on mouse clicked. Now i can pop up menu on left click. But now my issue is, i am not able to remove right click functionality. I think this is in built function for system tray menu. please help or give suggestions on this issue. I think that the way which i used to pop up menu on left click is not a good one. If i removed right click then this code may not work.
    Thank you,
    Sreejith P.M.
    Edited by: Sreeksd on Jan 6, 2011 11:39 PM

  • Only popup menu possible in system tray ?

    hello,
    want to run my app in the system tray. so far no problem. But i would like to show a small msg box appearing and showing a msg and when the user clicks on the msg box it should disappear.
    Is this possible?

    There is no way in the standard java libraries. Try google.

  • "Java Applet Window" appears in my popup menu

    Hello
    I have added a popup menu to my applet but whenever the popup menu appears, I also get the text "Java Applet Window" at its bottom.
    What is causing this?
    Can I get rid of it?

    Yes you can add a local user policy or local system policy that grants an AWT permission that regards "Java Applet Window" more precisely permission java.awt.AWTPermission "showWindowWithoutWarningBanner";
    You can use a tool to add policy, create new policy files etc. Read about "policytool" in http://java.sun.com/j2se/1.4.1/docs/tooldocs/tools.html
    Probably, signing tha applet jar, you can obtain necessary permission without modifing local policy. But I'm not sure.
    Stefano.

  • Attaching window system tray icon events to java frame

    I need to bring java frame to front on an event with the icon placed in the system tray. Like if I click the mouse on it.. the frame should come to front.
    Any body who can help, I will really appreciate.
    Thanks in advance
    Zeeshan

    I am very interested in implementing just such a thing with my Java application. I am in the starting phases of this project and ran across your post in my search for info.
    How much do you already have implemented? I.E., can you display the icon but are just having trouble catching the events for when the icon is clicked? Or do you not even have the ability to display the icon yet? I have found the Windows documentation on the MSDN site for the shell function Shell_NotifyIcon(), which is what we want to use but I have not begun any attempts to use it yet.
    If you (or anyone else) have any info or have had any success at all with this yet, I would be very interested in hearing how it works. I'll be happy to share any info I find, when/if I get that far.
    Thanks,
    j

  • How to put Java application in the MS. Windows System tray

    dear all,
    Is it possible to make a Java application communicate with the MS. Explorer and to put a Java application in the MS. Windows System tray
    Regards

    http://www.esus.com/docs/GetQuestionPage.jsp?uid=624
    or look for madcap on sourceforge

Maybe you are looking for

  • DropDownbyKey Problem with displayed values

    Hi all, I've got some strange behaviors with some dropDownbyKey. These DropDownbyKey are linked to enumerations. In our projects we use several DCs. 4 DCs have been developed separately. Since we refer in our master DCs to the 3 others DCs, dropdownb

  • Sql query slow from application but executes in 1 min in Toad

    Hello, When I execute a big select query from DB itself , it gives results in a min. But when called from .Net application it takes 10 mins to execute. But after trying to excute no of times, it suddenly works faster sometimes.

  • "thinkpad video features" update fails and breaks machine. Anyone else got this?

    The update is "thinkpad video features [...Quadro 1000M/2000M Optimus] for Windows 7 64" version 8.17.12.7593/8.15.10.2538. It failed (gave an error message during install allong the lines of "update failed"). After this, I could not play any Direct-

  • Good chroma keying app for ipod 4g?

           Does anyone know of a good app for chroma keying (or green screening) on the ipod touch 4g? I have seen like ten or so, but was wondering if anyone here has used one that they really like?        Also if anyone knows of a good video editing ap

  • Metadata Integrator

    I have problems to get the Metadata Integrator work properly. When I'm doing a lineage analysis from a report in the Management Console I got the error message "Unable to retrieve columns from Data Services". Data Services 3.1 is running on a Win 200