Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

launch Applet from another program

 
sudipto shekhar
Ranch Hand
Posts: 826
Chrome Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to start an applet "MyApplet" from one of my application.

How do I do that?

Please Help.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by "start"? In a browser? In appletviewer? In a window of your -desktop?- application? Something else?
 
sudipto shekhar
Ranch Hand
Posts: 826
Chrome Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thnx for the reply.

I want to start it in an appletviewer or a window
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you have an HTML file that contains the applet tag, you can start appletviewer using Runtime.exec or the ProcessBuilder class. The HTML file would be a parameter on the command line (just like you'd run appletviewer normally).

If you want it to be part of your application, you can the class that extends applet to a Frame (of JFrame), since Applet extends Panel. Call init(), and then start() and stop() as appropriate. Be aware that you lose some applet features when doing it like this (namely, parameters and the applet context).
 
sudipto shekhar
Ranch Hand
Posts: 826
Chrome Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you.that was great and very clear.
 
sudipto shekhar
Ranch Hand
Posts: 826
Chrome Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An example would help,please.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An example of what? I mentioned several ways; which one are you pursuing? What do you have so far?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic