Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Applet outside a browser>

 
cardwell cupp
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible to run an applet outside a browser. If so, how do you do it>?
Thanks all
cardwell (greenest horn)
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
I don't think so. The thing that makes Applet an Applet is that you do no have a main method. That the browser do this for you.
You can use Appletviewer if you don't feel like open a browser for your applet.
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since Applet extends Panel, you can add it into any GUI just like a Panel. All the applet specific stuff ( like getAppletContext(), getImage(), etc. ) won't work though...

-Nate
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can view and applet in an applet-viewer outside of a browser. An applet viewer is a tool that implements the same behaviors towards applets as a browser would.
The contract that a browser has with an applet is that it will understand how to use 4 methods.

It will begin the applet by calling the init() method.
Every time the page is redisplayed (for instance after the browser has been minimized and then re-displayed) it will call the start() method allowing the applet to re-kickoff any animations or audios.
It will call the stop() method every time the page is not being displayed (like when it gets minimized). This allows you the chance to stop animations which would waste resources when not been viewed, and turn off audios which might annoy your user if the applet is not currently being displayed.
It will call the destroy() method to release any resources when the applet is completed in some manner.
[This message has been edited by Cindy Glass (edited September 13, 2001).]
 
Geoffrey Falk
Ranch Hand
Posts: 171
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you can do this by creating a main() method in a separate class. Remember that Applet extends Panel, so you can add an Applet to a Frame. For example,
<PRE>
class MyApplet extends Applet { .... }
class Standalone extends Frame {
Applet myApplet;
Standalone() {
add(myApplet = new MyApplet());
myApplet.init();
myApplet.start();
}
public static void main(String[] args) {
new Standalone();
}
}
</PRE>
Then you can run it either in a browser, with appletviewer, or from the command line with "java Standalone".
Regards
Geoffrey

------------------
Sun Certified Programmer for the Java 2 Platform
[This message has been edited by Geoffrey Falk (edited September 14, 2001).]
[This message has been edited by Geoffrey Falk (edited September 14, 2001).]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic