Results 1 to 16 of 16
Thread: I need help is very urgent
- 06-24-2010, 06:37 PM #1
Member
- Join Date
- Jun 2010
- Posts
- 3
- Rep Power
- 0
I need help is very urgent
here is my source code: java applet
my problem is that in the html page the icon is not displayed.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."); } } } }
Thank you for your supportLast edited by Eranga; 06-24-2010 at 07:29 PM. Reason: code tags added
- 06-24-2010, 07:01 PM #2
Senior Member
- Join Date
- Dec 2008
- Posts
- 526
- Rep Power
- 0
Is the applet in its JAR ?
- 06-24-2010, 07:30 PM #3
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
You cannot do this from the applet, it dosen't have the control over the user desktop.
- 06-24-2010, 07:32 PM #4
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
At least, did you debug the code?
- 06-24-2010, 07:47 PM #5
Senior Member
- Join Date
- Dec 2008
- Posts
- 526
- Rep Power
- 0
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 :)
- 06-24-2010, 08:00 PM #6
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
- 06-24-2010, 08:25 PM #7
Senior Member
- Join Date
- Dec 2008
- Posts
- 526
- Rep Power
- 0
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 :)
- 06-25-2010, 02:45 AM #8
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Agreed. But even as you said applet can be run as a desktop application, which not tried by OP. :)
- 06-25-2010, 09:52 AM #9
Member
- Join Date
- Jun 2010
- Posts
- 3
- Rep Power
- 0
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
- 06-25-2010, 01:13 PM #10
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.how to put the applet and the image in a file. jar
- 06-26-2010, 02:13 AM #11
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
- 06-26-2010, 03:52 AM #12
Senior Member
- Join Date
- Dec 2008
- Posts
- 526
- Rep Power
- 0
- 06-26-2010, 04:58 AM #13
- 06-26-2010, 05:01 AM #14
Senior Member
- Join Date
- Dec 2008
- Posts
- 526
- Rep Power
- 0
- 06-26-2010, 01:40 PM #15
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
- 06-27-2010, 03:08 AM #16
Senior Member
- Join Date
- Dec 2008
- Posts
- 526
- Rep Power
- 0
Watch your code closely. You are trying to access the system tray :rolleyes:
Browser is not about here :D
watch it
That's why I recommend you to use a JWS application way ;)Java Code:if (SystemTray.isSupported()) { SystemTray tray = SystemTray.getSystemTray(); Image image = Toolkit.getDefaultToolkit().getImage("tray.gif");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
-
[URGENT]SHA Encryption System...need urgent helps
By java_idiot in forum New To JavaReplies: 6Last Post: 05-02-2010, 10:04 AM -
Urgent
By Anchal in forum Java ServletReplies: 1Last Post: 04-10-2010, 05:35 PM -
very urgent
By nehaa in forum NetworkingReplies: 12Last Post: 01-23-2009, 05:46 PM -
Hi, need some urgent help!
By jdark in forum New To JavaReplies: 2Last Post: 04-18-2008, 06:50 AM -
Help me ...urgent!
By googgoo in forum New To JavaReplies: 7Last Post: 04-05-2008, 08:46 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks