dcsimg
How to launch a Swing app from an Applet?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   circuit_breaker
Posted On:   Tuesday, May 6, 2003 06:30 AM

Hi,

As the title says, can it be done? How?

Thanks.

Re: How to launch a Swing app from an Applet?

Posted By:   Bahman_Barzideh  
Posted On:   Tuesday, May 6, 2003 07:31 AM

You should be able to do this. I would think the real issue would not be how to mechanics of starting the program but getting around environment and security issues. There are two ways to start the program.
  • Simple way: Your Swing application must be extending a JFrame (lets call it MyApp).
    You can simply create an instance of your MyApp in your
    Applet, pack () it and call setVisible (true) on
    it. This should create and display your application window.
  • More complex way: start the program using one of the Runtime.exec () methods. For example Runtime.exec ("java MyApp");.



    Now for the real issues you need to worry about.

  • First, your user must have downloaded MyApp (and all classes it uses) or you must
    download them as part of your Applet prior to starting MyApp.

  • I am almost sure you will hit some security issues and exception.
    Unfortunately, I am not familiar enough with these to help you with
    what they might be.

  • You need to worry about the version of Java the user has on his/her machine and their classpath.



    Please note that if you are running the applet on your local machine, you
    probably will not face the above issues but will hit them as soon as you
    try to use the Applet across the net on someone else's machine.
  • About | Sitemap | Contact