• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Unable to set label icon

 
Greenhorn
Posts: 26
Firefox Browser Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 26
Firefox Browser Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Apple still not initialised.
 
Mahendra Kariya
Greenhorn
Posts: 26
Firefox Browser Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Local files cannot be accessed from an applet unless applet is digitally signed. What a silly mistake...!
 
Mahendra Kariya
Greenhorn
Posts: 26
Firefox Browser Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks to AndrewThompson64 on Sun Forums. I changed the file path to URL and it worked fine. The code for that is below.

 
She's brilliant. She can see what can be and is not limited to what is. And she knows this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic