Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

invoke applet

 
biswajit goswami
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how to invoke an applet from another class??
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That depends on what you mean by "invoke". An applet is a class like any other, so if you need to call methods in it, you do in the same way you would with any other class. That would not be a good design, though - the applet class should only contain methods related directly to the running of the applet. Everything else should be in other classes.

If you mean something else by "invoke", describe it in more detail.
 
biswajit goswami
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
invoke=execute........the applet should run from another class........just constructor wont do...the paint(graphics g) needs g,who will provide it?has anybody succeeded in doing it?
 
fedai gandjaliyev
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If by "invoke" you mean to diplay the page then just call the page
and it will load the applet and it will be "invoked".
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An applet is a graphical component (it extends java.awt.Panel), so you can't just "run" it, you need to add it to a GUI that you have somewhere. Then the paint method will be called automatically.
Note that if you do this, the init, start, stop and destroy methods will not be called automatically (as happens in a browser) - your code needs to do that. Also, any functionality that depends on AppletContext or AppletStub will be unavailable.
As I said before, refactor the applet code so that all the general code (which is not specific to applets) is not in the applet class, but in auxiliary classes, which you then can use independently.
Or is this an applet to which you don't have the source?
[ December 07, 2005: Message edited by: Ulf Dittmer ]
 
biswajit goswami
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have MyApplet extends Applet{
..}
I want to run this MyApplet from another class,say AppletCaller.
So,has anybody bypassed the applet constraints to run the applet directly from another class.....can u show me some code?
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't mention whether AppletCaller is an applet or an application. If it's an application, then the MainFrame class (see the Applet FAQ for a link) can help you with this.
 
biswajit goswami
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
its an application and i shall go through MainFrame...........What if AppletCaller is an applet??
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then you need to go with my earlier suggestion of treating it as a GUI component.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic