SlideShare a Scribd company logo
GUI IN JAVA

    What is an Applet?

Introduction

Applet is java program that can be embedded into HTML pages. Java applets run on the java
enables web browsers such as Mozilla and internet explorer. Applet is designed to run
remotely on the client browser, so there are some restrictions on it. Applet can't access
system resources on the local computer. Applets are used to make the web site more
dynamic and entertaining.

Advantages of Applet:

       Applets are cross platform and can run on Windows, Mac OS and Linux platform
       Applets can work all the version of Java Plug-in
       Applets are supported by most web browsers
       Applets are cached in most web browsers, so will be quick to load when returning to
       a web page
       User can also have full access to the machine if user allows

Disadvantages of Java Applet:

       Java plug-in is required to run applet
       Java applet requires JVM so first time it takes significant start-up time
       If applet is not already cached in the machine, it will be downloaded from internet
       and will take time
       It’s difficult to design and build good user interface in applets compared to HTML
       technology

Applet versus Application

       Applets as previously described, are the small programs while applications are larger
       programs.
       Applets don't have the main method while in an application execution starts with
       the main method.
       Applets can run in our browser's window or in an appletviewer. To run the applet in
       an appletviewer will be an advantage for debugging.
       Applets are designed for the client site programming purpose while the applications
       don't have such type of criteria.

       Applet is the powerful tools because it covers half of the java language picture. Java
       applets are the best way of creating the programs in java. There are a less number of
       java programmers that have the hands on experience on java applications.
       Applications are also the platform independent as well as byte oriented just like the
       applets.
Applets are designed just for handling the client site problems. While the java
           applications are designed to work with the client as well as server.
           Applications are designed to exist in a secure area. While the applets are typically
           used.

Applications and applets have much of the similarity such as both have most of the same
features and share the same resources. Applets are created by extending the
java.applet.Applet class while the java applications start execution from the main method.
Applications are not too small to embed into a html page so that the user can view the
application in your browser. On the other hand applet has the accessibility criteria of the
resources. The key feature is that while they have so many differences but both can perform
the same purpose.

     The Life cycle of an Applet


Introduction

In this Section you will learn about the lifecycle of an applet and different methods of an
applet. Applet runs in the browser and its lifecycle method are called by JVM when it is
loaded and destroyed. Here are the lifecycle methods of an Applet:




init( )

The init( ) method is the first method to be called. This is where you should initialize
variables. This method is called only once during the run time of your applet.

start( )
The start( ) method is called after init( ). It is also called to restart an applet after it has been
stopped. Whereas init( ) is called once—the first time an applet is loaded—start( ) is called
each time an applet’s HTML document is displayed onscreen. So, if a user leaves a web page
and comes back, the applet resumes execution at start( ).

paint( )

The paint( ) method is called each time your applet’s output must be redrawn. This situation
can occur for several reasons. For example, the window in which the applet is running may
be overwritten by another window and then uncovered. Or the applet window may be
minimized and then restored. paint( ) is also called when the applet begins execution.
Whatever the cause, whenever the applet must redraw its output, paint( ) is called. The
paint( ) method has one parameter of type Graphics. This parameter will contain the
graphics context, which describes the graphics environment in which the applet is running.
This context is used whenever output to the applet is required.

stop( )

The stop( ) method is called when a web browser leaves the HTML document containing the
applet—when it goes to another page, for example. When stop( ) is called, the applet is
probably running. You should use stop( ) to suspend threads that don’t need to run when
the applet is not visible. You can restart them when start( ) is called if the user returns to the
page.

destroy( )

The destroy( ) method is called when the environment determines that your applet needs
to be removed completely from memory. At this point, you should free up any resources the
applet may be using. The stop( ) method is always called before destroy( ).

More Related Content

What's hot

Applet programming in java
Applet programming in javaApplet programming in java
Applet programming in java
Vidya Bharti
 
Basics of applets.53
Basics of applets.53Basics of applets.53
Basics of applets.53
myrajendra
 
Applet
AppletApplet
Java applet basics
Java applet basicsJava applet basics
Java applet basics
Sunil Pandey
 
Java applet
Java appletJava applet
Java applet
Arati Gadgil
 
Appletjava
AppletjavaAppletjava
Appletjava
DEEPIKA T
 
ITFT- Applet in java
ITFT- Applet in javaITFT- Applet in java
ITFT- Applet in java
Atul Sehdev
 
applet using java
applet using javaapplet using java
applet using java
Kartik Kalpande Patil
 
L18 applets
L18 appletsL18 applets
L18 applets
teach4uin
 
Java applets
Java appletsJava applets
Java applets
Khan Mac-arther
 
Java Applet
Java AppletJava Applet
Java Applet
Athharul Haq
 
Java applets
Java appletsJava applets
Java applets
M Vishnuvardhan Reddy
 
27 applet programming
27  applet programming27  applet programming
27 applet programming
Ravindra Rathore
 
Applet init nd termination.59
Applet init nd termination.59Applet init nd termination.59
Applet init nd termination.59
myrajendra
 
Java Applet
Java AppletJava Applet
Applet progming
Applet progmingApplet progming
Applet progming
VIKRANTHMALLIKARJUN
 
Applet (1)
Applet (1)Applet (1)
Applet (1)
DEEPIKA T
 
6.applet programming in java
6.applet programming in java6.applet programming in java
6.applet programming in java
Deepak Sharma
 
JAVA APPLETS
JAVA APPLETSJAVA APPLETS
JAVA APPLETS
Ramkrishna bhagat
 
Applet programming
Applet programming Applet programming
Applet programming
Devyani Vaidya
 

What's hot (20)

Applet programming in java
Applet programming in javaApplet programming in java
Applet programming in java
 
Basics of applets.53
Basics of applets.53Basics of applets.53
Basics of applets.53
 
Applet
AppletApplet
Applet
 
Java applet basics
Java applet basicsJava applet basics
Java applet basics
 
Java applet
Java appletJava applet
Java applet
 
Appletjava
AppletjavaAppletjava
Appletjava
 
ITFT- Applet in java
ITFT- Applet in javaITFT- Applet in java
ITFT- Applet in java
 
applet using java
applet using javaapplet using java
applet using java
 
L18 applets
L18 appletsL18 applets
L18 applets
 
Java applets
Java appletsJava applets
Java applets
 
Java Applet
Java AppletJava Applet
Java Applet
 
Java applets
Java appletsJava applets
Java applets
 
27 applet programming
27  applet programming27  applet programming
27 applet programming
 
Applet init nd termination.59
Applet init nd termination.59Applet init nd termination.59
Applet init nd termination.59
 
Java Applet
Java AppletJava Applet
Java Applet
 
Applet progming
Applet progmingApplet progming
Applet progming
 
Applet (1)
Applet (1)Applet (1)
Applet (1)
 
6.applet programming in java
6.applet programming in java6.applet programming in java
6.applet programming in java
 
JAVA APPLETS
JAVA APPLETSJAVA APPLETS
JAVA APPLETS
 
Applet programming
Applet programming Applet programming
Applet programming
 

Viewers also liked

Lecture7 oopj
Lecture7 oopjLecture7 oopj
Lecture7 oopj
Dhairya Joshi
 
Sistema Génesis y Portales Institucionales
Sistema Génesis y Portales InstitucionalesSistema Génesis y Portales Institucionales
Sistema Génesis y Portales Institucionales
Miguel_arci
 
Lecture6 oopj
Lecture6 oopjLecture6 oopj
Lecture6 oopj
Dhairya Joshi
 
Lecture3 oopj
Lecture3 oopjLecture3 oopj
Lecture3 oopj
Dhairya Joshi
 
02 Hidup ini Pilihan
02 Hidup ini Pilihan02 Hidup ini Pilihan
02 Hidup ini Pilihan
tsabitamuninggar
 
Lecture4 oopj
Lecture4 oopjLecture4 oopj
Lecture4 oopj
Dhairya Joshi
 
Lecture2 oopj
Lecture2 oopjLecture2 oopj
Lecture2 oopj
Dhairya Joshi
 
Lecture5 oopj
Lecture5 oopjLecture5 oopj
Lecture5 oopj
Dhairya Joshi
 
Lecture10 oopj
Lecture10 oopjLecture10 oopj
Lecture10 oopj
Dhairya Joshi
 
Presentacion
PresentacionPresentacion
Presentacion
Anabel Yera
 

Viewers also liked (10)

Lecture7 oopj
Lecture7 oopjLecture7 oopj
Lecture7 oopj
 
Sistema Génesis y Portales Institucionales
Sistema Génesis y Portales InstitucionalesSistema Génesis y Portales Institucionales
Sistema Génesis y Portales Institucionales
 
Lecture6 oopj
Lecture6 oopjLecture6 oopj
Lecture6 oopj
 
Lecture3 oopj
Lecture3 oopjLecture3 oopj
Lecture3 oopj
 
02 Hidup ini Pilihan
02 Hidup ini Pilihan02 Hidup ini Pilihan
02 Hidup ini Pilihan
 
Lecture4 oopj
Lecture4 oopjLecture4 oopj
Lecture4 oopj
 
Lecture2 oopj
Lecture2 oopjLecture2 oopj
Lecture2 oopj
 
Lecture5 oopj
Lecture5 oopjLecture5 oopj
Lecture5 oopj
 
Lecture10 oopj
Lecture10 oopjLecture10 oopj
Lecture10 oopj
 
Presentacion
PresentacionPresentacion
Presentacion
 

Similar to Lecture1 oopj

Class notes(week 10) on applet programming
Class notes(week 10) on applet programmingClass notes(week 10) on applet programming
Class notes(week 10) on applet programming
Kuntal Bhowmick
 
JAVA INTRODUCTION
JAVA INTRODUCTIONJAVA INTRODUCTION
JAVA INTRODUCTION
Prof Ansari
 
JAVA INTRODUCTION
JAVA INTRODUCTIONJAVA INTRODUCTION
JAVA INTRODUCTION
Prof Ansari
 
Advanced Programming, Java Programming, Applets.ppt
Advanced Programming, Java Programming, Applets.pptAdvanced Programming, Java Programming, Applets.ppt
Advanced Programming, Java Programming, Applets.ppt
miki304759
 
Java applets
Java appletsJava applets
Java applets
Pihu Goel
 
Class notes(week 10) on applet programming
Class notes(week 10) on applet programmingClass notes(week 10) on applet programming
Class notes(week 10) on applet programming
Kuntal Bhowmick
 
JAVA.pptx
JAVA.pptxJAVA.pptx
Java
JavaJava
UNIT-1-AJAVA.pdf
UNIT-1-AJAVA.pdfUNIT-1-AJAVA.pdf
UNIT-1-AJAVA.pdf
PriyanshiPrajapati27
 
Applets in Java
Applets in JavaApplets in Java
Applets in Java
RamaPrabha24
 
Java applet
Java appletJava applet
Java applet
Elizabeth alexander
 
Jsp applet
Jsp appletJsp applet
Jsp applet
Sanoj Kumar
 
Applet1 (1).pptx
Applet1 (1).pptxApplet1 (1).pptx
Applet1 (1).pptx
FahanaAbdulVahab
 
APPLET.pptx
APPLET.pptxAPPLET.pptx
APPLET.pptx
SHANMUGARAJA K
 
Applet
AppletApplet
Applet
Amir Shokri
 
Applets in Java
Applets in JavaApplets in Java
Applets in Java
Gary Mendonca
 
Applet
AppletApplet
Applet
pawan2579
 
Chapter_7_-_EV_-_OOP[1].pdf
Chapter_7_-_EV_-_OOP[1].pdfChapter_7_-_EV_-_OOP[1].pdf
Chapter_7_-_EV_-_OOP[1].pdf
zekishamanch
 
Java basics notes
Java basics notesJava basics notes
Java basics notes
sanchi Sharma
 
Java basics notes
Java basics notesJava basics notes
Java basics notes
Nexus
 

Similar to Lecture1 oopj (20)

Class notes(week 10) on applet programming
Class notes(week 10) on applet programmingClass notes(week 10) on applet programming
Class notes(week 10) on applet programming
 
JAVA INTRODUCTION
JAVA INTRODUCTIONJAVA INTRODUCTION
JAVA INTRODUCTION
 
JAVA INTRODUCTION
JAVA INTRODUCTIONJAVA INTRODUCTION
JAVA INTRODUCTION
 
Advanced Programming, Java Programming, Applets.ppt
Advanced Programming, Java Programming, Applets.pptAdvanced Programming, Java Programming, Applets.ppt
Advanced Programming, Java Programming, Applets.ppt
 
Java applets
Java appletsJava applets
Java applets
 
Class notes(week 10) on applet programming
Class notes(week 10) on applet programmingClass notes(week 10) on applet programming
Class notes(week 10) on applet programming
 
JAVA.pptx
JAVA.pptxJAVA.pptx
JAVA.pptx
 
Java
JavaJava
Java
 
UNIT-1-AJAVA.pdf
UNIT-1-AJAVA.pdfUNIT-1-AJAVA.pdf
UNIT-1-AJAVA.pdf
 
Applets in Java
Applets in JavaApplets in Java
Applets in Java
 
Java applet
Java appletJava applet
Java applet
 
Jsp applet
Jsp appletJsp applet
Jsp applet
 
Applet1 (1).pptx
Applet1 (1).pptxApplet1 (1).pptx
Applet1 (1).pptx
 
APPLET.pptx
APPLET.pptxAPPLET.pptx
APPLET.pptx
 
Applet
AppletApplet
Applet
 
Applets in Java
Applets in JavaApplets in Java
Applets in Java
 
Applet
AppletApplet
Applet
 
Chapter_7_-_EV_-_OOP[1].pdf
Chapter_7_-_EV_-_OOP[1].pdfChapter_7_-_EV_-_OOP[1].pdf
Chapter_7_-_EV_-_OOP[1].pdf
 
Java basics notes
Java basics notesJava basics notes
Java basics notes
 
Java basics notes
Java basics notesJava basics notes
Java basics notes
 

Lecture1 oopj

  • 1. GUI IN JAVA  What is an Applet? Introduction Applet is java program that can be embedded into HTML pages. Java applets run on the java enables web browsers such as Mozilla and internet explorer. Applet is designed to run remotely on the client browser, so there are some restrictions on it. Applet can't access system resources on the local computer. Applets are used to make the web site more dynamic and entertaining. Advantages of Applet: Applets are cross platform and can run on Windows, Mac OS and Linux platform Applets can work all the version of Java Plug-in Applets are supported by most web browsers Applets are cached in most web browsers, so will be quick to load when returning to a web page User can also have full access to the machine if user allows Disadvantages of Java Applet: Java plug-in is required to run applet Java applet requires JVM so first time it takes significant start-up time If applet is not already cached in the machine, it will be downloaded from internet and will take time It’s difficult to design and build good user interface in applets compared to HTML technology Applet versus Application Applets as previously described, are the small programs while applications are larger programs. Applets don't have the main method while in an application execution starts with the main method. Applets can run in our browser's window or in an appletviewer. To run the applet in an appletviewer will be an advantage for debugging. Applets are designed for the client site programming purpose while the applications don't have such type of criteria. Applet is the powerful tools because it covers half of the java language picture. Java applets are the best way of creating the programs in java. There are a less number of java programmers that have the hands on experience on java applications. Applications are also the platform independent as well as byte oriented just like the applets.
  • 2. Applets are designed just for handling the client site problems. While the java applications are designed to work with the client as well as server. Applications are designed to exist in a secure area. While the applets are typically used. Applications and applets have much of the similarity such as both have most of the same features and share the same resources. Applets are created by extending the java.applet.Applet class while the java applications start execution from the main method. Applications are not too small to embed into a html page so that the user can view the application in your browser. On the other hand applet has the accessibility criteria of the resources. The key feature is that while they have so many differences but both can perform the same purpose.  The Life cycle of an Applet Introduction In this Section you will learn about the lifecycle of an applet and different methods of an applet. Applet runs in the browser and its lifecycle method are called by JVM when it is loaded and destroyed. Here are the lifecycle methods of an Applet: init( ) The init( ) method is the first method to be called. This is where you should initialize variables. This method is called only once during the run time of your applet. start( )
  • 3. The start( ) method is called after init( ). It is also called to restart an applet after it has been stopped. Whereas init( ) is called once—the first time an applet is loaded—start( ) is called each time an applet’s HTML document is displayed onscreen. So, if a user leaves a web page and comes back, the applet resumes execution at start( ). paint( ) The paint( ) method is called each time your applet’s output must be redrawn. This situation can occur for several reasons. For example, the window in which the applet is running may be overwritten by another window and then uncovered. Or the applet window may be minimized and then restored. paint( ) is also called when the applet begins execution. Whatever the cause, whenever the applet must redraw its output, paint( ) is called. The paint( ) method has one parameter of type Graphics. This parameter will contain the graphics context, which describes the graphics environment in which the applet is running. This context is used whenever output to the applet is required. stop( ) The stop( ) method is called when a web browser leaves the HTML document containing the applet—when it goes to another page, for example. When stop( ) is called, the applet is probably running. You should use stop( ) to suspend threads that don’t need to run when the applet is not visible. You can restart them when start( ) is called if the user returns to the page. destroy( ) The destroy( ) method is called when the environment determines that your applet needs to be removed completely from memory. At this point, you should free up any resources the applet may be using. The stop( ) method is always called before destroy( ).