APPLET SKELETON

An Applet Skeleton

Most applets override these four methods. These four methods forms Applet lifecycle.
  • init() : init() is the first method to be called. This is where variable are initialized. This method is called only once during the runtime of applet.
  • start() : start() method is called after init(). This method is called to restart an applet after it has been stopped.
  • stop() : stop() method is called to suspend thread that does not need to run when applet is not visible.
  • destroy() : destroy() method is called when your applet needs to be removed completely from memory.

Example of an Applet Skeleton

import java.awt.*; 
import java.applet.*; 
public class AppletTest extends Applet
{
 public void init()
 {
  //initialization 
 }
 public void start ()
 {
  //start or resume execution 
 }
 public void stop()
 {
  //suspend execution 
 {
 public void destroy()
 {
  //perform shutdown activity
 }
 public void paint (Graphics g)
 {
  //display the content of window
 }
}

Example of an Applet

import java.applet.*;
import java.awt.*;
public class MyApplet extends Applet 
{
 int height, width;
 public void init() 
 {
  height = getSize().height;
  width = getSize().width;
  setName("MyApplet");
 }
 public void paint(Graphics g)
 {
  g.drawRoundRect(10, 30, 120, 120, 2, 3);
 }
}
applet example

Running Applet using Applet Viewer

To execute an Applet with an applet viewer, write short HTML file as discussed above. If name it as run.htm, then the following command will run your applet program.
f:/>appletviewer run.htm
running applet using applet viewer

16 comments:

  1. This is an awesome post.Really very informative and creative contents. These concept is a good way to enhance the knowledge.
    I like it and help me to development very well.Thank you for this brief explanation and very nice information.Well, got a good knowledge.
    Java training in Chennai
    Java training in Bangalore
    Java online training
    Java training in Pune






    ReplyDelete
  2. Hmm, it seems like your site ate my first comment (it was extremely long) so I guess I’ll just sum it up what I had written and say, I’m thoroughly enjoying your blog. I as well as an aspiring blog writer, but I’m still new to the whole thing. Do you have any recommendations for newbie blog writers? I’d appreciate it.
    AWS Course Interview Questions and Answers for Freshers | AWS Interviews Questions and Answers for Devops
    AWS Interview questions and answers for Sysops |AWS Interview Question and Answers BlogSpot

    ReplyDelete
  3. Excellant post!!!. The strategy you have posted on this technology helped me to get into the next level and had lot of information in it.
    AWS Training in Bangalore

    ReplyDelete
  4. This is very usefull and understable

    ReplyDelete
  5. Thanks for splitting your comprehension with us. It’s really useful to me & I hope it helps the people who in need of this vital information.
    thanks lot!!!

    Android Training in Chennai

    Android Online Training in Chennai

    Android Training in Bangalore

    Android Training in Hyderabad

    Android Training in Coimbatore

    Android Training

    Android Online Training

    ReplyDelete
  6. This post is so usefull and informaive keep updating with more information.....
    Data Science Courses in Bangalore
    Data Science Training in Bangalore

    ReplyDelete
  7. Great read! Your detailed explanation of the Applet Skeleton and the example provided have made Java applets much more understandable for me.
    Also Read: Java Message Queues (MQ): Unlocking Efficient Data Communication

    ReplyDelete
  8. This comment has been removed by the author.

    ReplyDelete
  9. I want to express gratitude for providing such valuable information. The insights gained are truly appreciated, and I'd like to recognize the significant time and effort you invested in assisting us. In the field of IT, effective leadership is pivotal for expediting success. The industry presents promising career opportunities with a diverse range of courses, encompassing Python, Software Testing, Data Science, Data Analytics, Java, and Full Stack Development. The recognized potential of a software testing course, in particular, is noteworthy. The career opportunities and future scope of Software Testing.

    ReplyDelete

  10. I appreciate your kind words! I'm delighted to hear that you enjoyed the content. If you have any more questions, need assistance, or if there's anything specific you'd like to explore, feel free to let me know. Happy reading, and I'm here to help with any information you may need.
    visit: Data Science Ethics and Privacy: Responsible Data Handling

    ReplyDelete
  11. great post, impressive , these java applet explanation helped me a lot to understand this issue and now i am taking classes of it with more details with java course in pune , thanks for this valuable post

    ReplyDelete
  12. this article is very helpful and immersive knowledge is shared by the admin, thanks for it from Best SEO Company in Delhi

    ReplyDelete
  13. Java Course in Pune is an object-oriented, class-based programming language that strongly focuses on minimizing implementation dependencies. Its goal is to give programmers the ability to write code once and run it anywhere (WORA), an idea that allows compiled Java code to execute on any platform that supports Java without requiring further compilation. Since its initial release in 1995, Java has become a widely used technology for designing desktop, online, and mobile applications. Java is a popular choice for enterprise-level applications because of its reputation for dependability, ease of use, and security features.
    James Gosling created Java in 1995 at Sun Microsystems Inc.; Oracle Corporation eventually purchased the program. It is an elementary language for programming. It is simpler to create, compile, and debug in Java.

    ReplyDelete