Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Applet an application

Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an requirement to run my Swing Japplet as an Applet or Application. Any help will be greatly appreciated.
Posts: 2205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JApplet/Applet are both descendants of Component, so you can add them to a Swing container.
What I have done is create my applet like you normally would first. Then, to make it an applicaiton, simply create a new class with a JFrame, and add the applet as a component to that JFrame. You have to call the applet's init() and start() methods at the start of the application. But after that, it will work exactly like it did in a browser. When you are quitting your application, you proably should call stop() on the applet, to mimick what a browser does when stopping the applet.
But since an applet is really just a component, you can treat it like you would any other AWT/Swing component in your application.
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well... that is pretty much true... the only difference is that the browser provides an AppletContext for the Applet to live in... there are some methods that will throw exceptions if an Applet is run outside of it's AppletContext (mostly things that deal with the applet's environment, like getting the current URL, or loading an Image...), so if you need to do any of these things you'll either need to build an AppletContext to put the Applet in, or you'll need to build some flags in your applet that get set based on how it is launched and test before calling any fuctions that rely on the AppletContext.

What I don't understand is how they changed the earth's orbit to fit the metric calendar. Tiny ad:
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic