aspose file tools*
The moose likes Applets and the fly likes Unable to set label icon Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "Unable to set label icon " Watch "Unable to set label icon " New topic
Author

Unable to set label icon

Mahendra Kariya
Greenhorn

Joined: Aug 25, 2008
Posts: 26

I am unable to initialise an applet when I set icon to a JLabel. The same code is running fine for JFrame. When I run the following code, it says "Applet not initialised". The image is in the same folder as that of the class file.

pete stein
Bartender

Joined: Feb 23, 2007
Posts: 1561
Per the applet tutorials, Sun recommends that Swing components be initialized on the EDT (Event Dispatch Thread) and inside an invokeAndWait method to allow time for the applet to initialize. So if you do this, does it work? e.g.,


Also, you may need to be careful with getting the ImageIcon this way if you plan to put the applet into a Jar.
Mahendra Kariya
Greenhorn

Joined: Aug 25, 2008
Posts: 26

Apple still not initialised.
Mahendra Kariya
Greenhorn

Joined: Aug 25, 2008
Posts: 26

Local files cannot be accessed from an applet unless applet is digitally signed. What a silly mistake...!
Mahendra Kariya
Greenhorn

Joined: Aug 25, 2008
Posts: 26

Thanks to AndrewThompson64 on Sun Forums. I changed the file path to URL and it worked fine. The code for that is below.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unable to set label icon