Results 1 to 20 of 20
  1. #1
    rameshraj is offline Member
    Join Date
    Dec 2007
    Posts
    42
    Rep Power
    0

    Thumbs up JAVA application residing on the windows tool bar!

    I want my java application to reside on the tools bar like the windows messenger and so on.Can i do this without a third party tool?or what would be the best tool for this?Any idea?

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

  3. #3
    rameshraj is offline Member
    Join Date
    Dec 2007
    Posts
    42
    Rep Power
    0

    Thumbs up

    Yes u r right.Can u help me?Can u provide some sample codes?

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    Try this,

    Java Code:
    import java.awt.AWTException;
    import java.awt.Image;
    import java.awt.Menu;
    import java.awt.MenuItem;
    import java.awt.PopupMenu;
    import java.awt.SystemTray;
    import java.awt.Toolkit;
    import java.awt.TrayIcon;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    
    /**
     *
     * @author Eranga Tennakoon
     */
    public class rameshraj {
    
        TrayIcon trayIcon;
        /**
         * @param args the command line arguments
         */
        public static void main(String[] args) {
            // TODO code application logic here
            new rameshraj().trayIconTest();
        }
        
        private void trayIconTest() {
            if (SystemTray.isSupported()) {
                try {
                    SystemTray tray = SystemTray.getSystemTray();
                    
                    ActionListener exitListener = new ActionListener(){
                        public void actionPerformed(ActionEvent e){
                            System.exit(0);
                        }
                    };
                    
                    PopupMenu popup = new PopupMenu();
                    MenuItem _one = new MenuItem("Exit");
                    Menu _two = new Menu("Item_Two");
                    
                    _one.addActionListener(exitListener);
                    
                    popup.add(_one);
                    popup.add(_two);
                    
                    Image image = Toolkit.getDefaultToolkit().getImage("RADAR.png");
                    trayIcon = new TrayIcon(image, "Java", popup);
                    trayIcon.setImageAutoSize(true);
    
                    
                    tray.add(trayIcon);
                }
                catch (AWTException e) 
                {
                    System.err.println("TrayIcon could not be added.");
                }
            }
            else {
                System.err.println("SystemTray is not supported.");
            }
        }
    
    }

  5. #5
    danielstoner's Avatar
    danielstoner is offline Senior Member
    Join Date
    Apr 2008
    Location
    Canada
    Posts
    191
    Rep Power
    6

    Default

    It is funny :) if you want to see almost the SAME way of doing it look here:
    More desktop integration: the system tray | Little Tutorials
    Daniel @ [www.littletutorials.com]
    Language is froth on the surface of thought

  6. #6
    rameshraj is offline Member
    Join Date
    Dec 2007
    Posts
    42
    Rep Power
    0

    Thumbs up

    Thank s for all of you.Actually I got good idea about the tray icon.But now can I be sure that after the OS starts the application resides in the toolbar as the tray icon or I need to run it manually every time the computer starts?

  7. #7
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

  8. #8
    rameshraj is offline Member
    Join Date
    Dec 2007
    Posts
    42
    Rep Power
    0

    Thumbs up

    For instance i have the application as a jar file: test.jar.
    Now where to put the jar file?There are many startup folders one for each application that are installed on the machine.
    Can u clarify me where to put the jar file and more about the startup folder?

  9. #9
    danielstoner's Avatar
    danielstoner is offline Senior Member
    Join Date
    Apr 2008
    Location
    Canada
    Posts
    191
    Rep Power
    6

    Default

    If you put it in the startup folder (there is one startup folder per user) the application will only run when somebody logs into the machine. Your solution is to run your application as a Windows Service as I said before in another thread. Unless you run on Windows 95 and you can use the RunServices Registry key. ;)
    Daniel @ [www.littletutorials.com]
    Language is froth on the surface of thought

  10. #10
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    Yes, as daniel says if you have many users on a single PC, need to include in each startup folder. It's not easy at all. So best thing is use a Windows Service.

    Why I talking about the startup folder is, if you can build a executable file easily you can define the place where you want to install the application.

  11. #11
    rameshraj is offline Member
    Join Date
    Dec 2007
    Posts
    42
    Rep Power
    0

    Thumbs up

    but how can this be done can u explain with some examples?

  12. #12
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

  13. #13
    rameshraj is offline Member
    Join Date
    Dec 2007
    Posts
    42
    Rep Power
    0

    Thumbs up

    how to add the jar or exe to the windows service without using any third party tool?I have been asking so far but only rounded answers are coming,can we come to the point?

  14. #14
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

  15. #15
    rameshraj is offline Member
    Join Date
    Dec 2007
    Posts
    42
    Rep Power
    0

    Thumbs up

    can u show how?Ex how to start the application as service?

  16. #16
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

  17. #17
    danielstoner's Avatar
    danielstoner is offline Senior Member
    Join Date
    Apr 2008
    Location
    Canada
    Posts
    191
    Rep Power
    6

    Default

    The point is that you have to use a third party tool or to write a service yourself. To write a service yourself it is not easy if you don't know C/C++ and Windows programming.
    Daniel @ [www.littletutorials.com]
    Language is froth on the surface of thought

  18. #18
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    And also you can use .Net as well. Most popular way to write windows services. Isn't it Daniel?

  19. #19
    danielstoner's Avatar
    danielstoner is offline Senior Member
    Join Date
    Apr 2008
    Location
    Canada
    Posts
    191
    Rep Power
    6

    Default

    It might very well be Eranga :) but I stopped being a Windows programmer before .NET was out on the market so I never had the pleasure ;)
    Daniel @ [www.littletutorials.com]
    Language is froth on the surface of thought

  20. #20
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

Similar Threads

  1. Java Application Interface similar with Windows Themes
    By Heracles Choe in forum AWT / Swing
    Replies: 9
    Last Post: 05-02-2008, 03:47 AM
  2. Check if Windows application is already open
    By mpiaser in forum Advanced Java
    Replies: 1
    Last Post: 12-07-2007, 09:56 PM
  3. Java SQL Admin Tool 2.4.2
    By JavaBean in forum Java Software
    Replies: 0
    Last Post: 11-12-2007, 06:05 PM
  4. First windows application
    By tha_crazy in forum New To Java
    Replies: 1
    Last Post: 08-13-2007, 03:22 PM
  5. Help with windows in java
    By lenny in forum AWT / Swing
    Replies: 1
    Last Post: 08-07-2007, 06:22 AM

Posting Permissions

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