Coding an Applet
- A Java Applet is a program that runs over the Internet. It is deprecated, but is a simple way to learn about writing code that is not just executed sequentially.
- An Applet is run by a plug-in to your browser, and that code knows when to call certain methods in your Applet code.
- Note: you do not write constructors for your Applet. The code that runs your Applet knows to call the default constructor.
- If you want code to execute when the Applet starts up, you put that code in the init() method.
- If you want code to execute when the Applet decides it needs to paint itself, you put that code into the paint() method.
- Unlinke the code we've seen so far, where each line of code is execute only when your program executes the code (line-by-line),
and must explicitly call a method for it to execute, Applet code automatically calls your methods for you.
- Also note that an Applet is not a console application, which means you cannot prompt for intput, but would write a graphcial interface (form) to allow the user to type in data.