Results 1 to 16 of 16
  1. #1
    ramroum is offline Member
    Join Date
    Jun 2010
    Posts
    3
    Rep Power
    0

    Default I need help is very urgent

    here is my source code: java applet

    Java Code:
    package org.me.hello;
    
    import java.applet.Applet;
    import java.awt.AWTException;
    import java.awt.BorderLayout;
    import java.awt.Button;
    import java.awt.Color;
    import java.awt.FlowLayout;
    import java.awt.Graphics;
    import java.awt.Image;
    import java.awt.MenuItem;
    import java.awt.Panel;
    import java.awt.PopupMenu;
    import java.awt.SystemTray;
    import java.awt.TextArea;
    import java.awt.TextField;
    import java.awt.Toolkit;
    import java.awt.TrayIcon;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JApplet;
    import javax.swing.JButton;
    import javax.swing.JPanel;
    import javax.swing.JTextField;
    
    
    
    public class AppletIcon extends JApplet implements ActionListener{
    private JButton ok = new JButton("Envoyer");
    private JTextField msg = new JTextField("",35);
        public void init(){
        //setLayout ( new BorderLayout());
         ok.addActionListener(this);
         this.getContentPane().add(ok,BorderLayout.SOUTH);
         this.getContentPane().add(msg,BorderLayout.NORTH);
    }
    public void actionPerformed(ActionEvent act) {
     
    final TrayIcon trayIcon;
    
    if (SystemTray.isSupported()) {
    
    SystemTray tray = SystemTray.getSystemTray();
    Image image = Toolkit.getDefaultToolkit().getImage("tray.gif");
    //PopupMenu popup = new PopupMenu();
    trayIcon = new TrayIcon(image, "Platforme");
    
    ActionListener actionListener = new ActionListener() {
    
    public void actionPerformed(ActionEvent e) {
    
    trayIcon.displayMessage("You have a new message", msg.getText(), TrayIcon.MessageType.INFO);
                         
            }
        };
    
    
    trayIcon.setImageAutoSize(true);
    
    trayIcon.addActionListener(actionListener);
    
    try {
            tray.add(trayIcon);
        }
    catch (AWTException e) {
            System.err.println("TrayIcon could not be added.");
    
     }
    
    
    }
    
     }
    
    }
    my problem is that in the html page the icon is not displayed.
    Thank you for your support
    Last edited by Eranga; 06-24-2010 at 07:29 PM. Reason: code tags added

  2. #2
    Webuser is offline Senior Member
    Join Date
    Dec 2008
    Posts
    526
    Rep Power
    0

    Default

    Is the applet in its JAR ?

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

  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
    20

  5. #5
    Webuser is offline Senior Member
    Join Date
    Dec 2008
    Posts
    526
    Rep Power
    0

    Default

    Emm...
    Applet can run as a desktop app unless it is signed.
    So do next:
    1) put your applet into jar
    2) put the image into jar
    3) invoke image as A.class.getResourceAsStream("*.PNG"); where A is an empty anchor class
    4) sign the applet jar

    And then I think that should work... If not come here again ;)
    If my answer helped you. Please click my "REP" button and add a comment
    Have a Good Java Coding :)

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

    Default

    Quote Originally Posted by Webuser View Post
    Emm...
    Applet can run as a desktop app unless it is signed.
    So do next:
    1) put your applet into jar
    2) put the image into jar
    3) invoke image as A.class.getResourceAsStream("*.PNG"); where A is an empty anchor class
    4) sign the applet jar

    And then I think that should work... If not come here again ;)
    Of course that's fine. But that's not what OP is tried. He dosen't do anything like that.

  7. #7
    Webuser is offline Senior Member
    Join Date
    Dec 2008
    Posts
    526
    Rep Power
    0

    Default

    But the author can replace applet with a JWS application and that would be more interesting I guess :)
    If my answer helped you. Please click my "REP" button and add a comment
    Have a Good Java Coding :)

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

    Default

    Agreed. But even as you said applet can be run as a desktop application, which not tried by OP. :)

  9. #9
    ramroum is offline Member
    Join Date
    Jun 2010
    Posts
    3
    Rep Power
    0

    Default

    thank you for your help.
    I'm a beginner in java is that you can tell me how to put the applet and the image in a file. jar

  10. #10
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,327
    Rep Power
    25

    Default

    how to put the applet and the image in a file. jar
    That's done using the jar command. Read the API doc for jar and also do a search for the many sample usages on the forum.

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

    Default

    Quote Originally Posted by ramroum View Post
    thank you for your help.
    I'm a beginner in java is that you can tell me how to put the applet and the image in a file. jar
    Check on Suns' tutorial as well. You can find lots of useful hints there.

  12. #12
    Webuser is offline Senior Member
    Join Date
    Dec 2008
    Posts
    526
    Rep Power
    0

    Default

    Quote Originally Posted by ramroum View Post
    thank you for your help.
    I'm a beginner in java is that you can tell me how to put the applet and the image in a file. jar
    You can do this easy with WinRAR program ;)
    Also with your IDE...
    Or study the jar util commands
    If my answer helped you. Please click my "REP" button and add a comment
    Have a Good Java Coding :)

  13. #13
    gafa's Avatar
    gafa is offline Senior Member
    Join Date
    Jun 2010
    Posts
    107
    Rep Power
    0

    Exclamation

    Quote Originally Posted by Webuser View Post
    You can do this easy with WinRAR program ;)
    Also with your IDE...
    Or study the jar util commands
    Webuser, please come back to my thread I am really not able to understand why my applet cannot run :(

  14. #14
    Webuser is offline Senior Member
    Join Date
    Dec 2008
    Posts
    526
    Rep Power
    0

    Default

    Quote Originally Posted by gafa View Post
    Webuser, please come back to my thread I am really not able to understand why my applet cannot run :(
    It's OK, gafa, I am watching the threads' list :)
    I am to come back a little bit later ...

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

    Default

    Quote Originally Posted by Webuser View Post
    Or study the jar util commands
    This is what I'm suggesting to move with as a Java developer. Better not to stick with other stuff at the time of learning the basis.

  16. #16
    Webuser is offline Senior Member
    Join Date
    Dec 2008
    Posts
    526
    Rep Power
    0

    Lightbulb

    Quote Originally Posted by ramroum View Post
    my problem is that in the html page the icon is not displayed.
    Thank you for your support
    Watch your code closely. You are trying to access the system tray :rolleyes:
    Browser is not about here :D

    watch it

    Java Code:
    if (SystemTray.isSupported()) {
    
    SystemTray tray = SystemTray.getSystemTray();
    Image image = Toolkit.getDefaultToolkit().getImage("tray.gif");
    That's why I recommend you to use a JWS application way ;)
    Last edited by Webuser; 06-27-2010 at 03:10 AM.
    If my answer helped you. Please click my "REP" button and add a comment
    Have a Good Java Coding :)

Similar Threads

  1. [URGENT]SHA Encryption System...need urgent helps
    By java_idiot in forum New To Java
    Replies: 6
    Last Post: 05-02-2010, 10:04 AM
  2. Urgent
    By Anchal in forum Java Servlet
    Replies: 1
    Last Post: 04-10-2010, 05:35 PM
  3. very urgent
    By nehaa in forum Networking
    Replies: 12
    Last Post: 01-23-2009, 05:46 PM
  4. Hi, need some urgent help!
    By jdark in forum New To Java
    Replies: 2
    Last Post: 04-18-2008, 06:50 AM
  5. Help me ...urgent!
    By googgoo in forum New To Java
    Replies: 7
    Last Post: 04-05-2008, 08:46 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
  •