Explain init(), start(), stop(), and destroy() method, JAVA Programming

Assignment Help:

Explain init(), start(), stop(), and destroy() method?

The init() method is known as exactly once in an applet's life, while the applet is first loaded. It's generally used to read PARAM tags, start downloading any other images or media files you required, and set up the user interface. Most applets have init() methods.

The start() method is called at least once in an applet's life, while the applet is begin or restarted. In some cases it may be known as more than once. Several applets you write will not have explicit start()methods and will merely inherit one from their superclass. A start() method is frequent used to start any threads the applet will required while it runs.

The stop() method is known as at least once in an applet's life, while the browser leaves the page in that case the applet is embedded. The applet's start() method will be called if at some later point the browser returns to the page containing the applet. In some cases the stop() method may be called multiple times in an applet's life. Several applets you write will not have explicit stop()methods and will merely inherit one from their superclass. Your applet should use the stop() method to pause any running threads. When your applet is stopped, it should not use any CPU cycles.

The destroy() method is known as exactly once in an applet's life, just before the browser unloads the applet. This method is commonly used to perform any final clean-up. For example, an applet that stores state on the server might send some data back to the server before it's terminated. many applets will not have explicit destroy() methods and just inherit one from their superclass.

For example, in a video applet, the init() method might draw the controls and start loading the video file. The start() method would wait until the file was loaded, and then start playing it. The stop() method would pause the video, but not rewind it. If the start() method were called again, the video would pick up where it left off; it would not start over from the beginning. However, if destroy() were called and then init(), the video would start over from the beginning.

In the JDK's appletviewer, selecting the Restart menu item calls stop() and then start(). Selecting the Reload menu item calls stop(), destroy(), and init(), in that order. (Generally the byte codes will also be reloaded and the HTML file reread by Netscape has a problem with this.)

The applet start() and stop() methods are not related to the same named methods in the java.lang.Thread class.
Your own code may occasionally invoke start() and stop(). For example, it's customary to stop playing an animation when the user clicks the mouse in the applet and restart it when they click the mouse again.

Your own code can also invoke init() and destroy(), but this is normally a bad idea. Only the environment should call init() and destroy().


Related Discussions:- Explain init(), start(), stop(), and destroy() method

Determine the meaning of finalize, Determine the meaning of finalize W...

Determine the meaning of finalize When  a  finalize method  is  defined  in  a  class,  Java  run  time  calls  finalize() whenever  it's  about  to  recycle  an object  of  t

Inheritance, Inheritance - is the inclusion of state and behavior of a ba...

Inheritance - is the inclusion of state and behavior of a base class in a derived class so that they are accessible in that derived class. The key benefit of Inheritance is that

Differentiate between smtp and pop3 server, Differentiate between SMTP and ...

Differentiate between SMTP and POP3 server? SMTP (Simple Mail Transfer Protocol) is a protocol used to send and receive eMail messages over a TCP/IP network. While POP3 (Post

How marketing strategies are changed along with the progress, How marketing...

How marketing strategies are changed along with the progress in computing? How latest marketing strategies are implemented? Marketing Strategy Changes along with the latest req

Creating applications based on soa, Creating applications based on SOA ...

Creating applications based on SOA Select your implementation technologies carefully. Carefully check if Web services are suitable. Sometimes using traditional methods suc

Mention five applications of artificial intelligent system, Mention any fiv...

Mention any five applications of Artificial Intelligent System? 1)Medical Diagnosis 2)Robots 3) Games 4) Business intelligence 5)Image Recognition.

Tictactoe, write complete application to play game tictactoe

write complete application to play game tictactoe

Static variable, import java.text.NumberFormat; import java.util.Locale; p...

import java.text.NumberFormat; import java.util.Locale; public class Client {    // instance data    private String name;    private long income_this_year;    private double perce

Forward action and include action, What is the difference among ForwardActi...

What is the difference among ForwardAction and IncludeAction? Ans) The difference is that you require to use the IncludeAction only if the action is going to be contained by ano

Develop a shopping carts application , To develop a shopping carts applicat...

To develop a shopping carts application for an online store of your choice Outcomes: 1. Apply the GUI components of Java and other tools to create user-friendly interfaces.

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd