Successfully reported this slideshow.
Applet Architecture Amit Kumar Saha B.Tech. (3 rd  year, Computer Science & Engineering ) College Roll No. 04/CS/20 Depart...
What are Applets? <ul><li>” Applets are small applications that are accessed on an Internet Server, transported over the I...
Functional Diagram of Applets
Applet Architecture <ul><li>Event driven </li></ul><ul><ul><li>An applet waits until an event occurs. </li></ul></ul><ul><...
The Applet API <ul><li>The API is provided by the  javax.swing.JApplet  class and the  java.applet.AppletContext  interfac...
Life cycle of an Applet <ul><li>init :  This method is intended for whatever initialization is needed for your applet. It ...
Methods for Milestones <ul><li>Following is the interface for these methods: </li></ul><ul><li>public class Simple extends...
Applet Skeleton <ul><li>public class Simple extends JApplet { </li></ul><ul><li>. . . </li></ul><ul><li>public void init()...
Program Execution Flow
Handling Events <ul><li>Applets inherit a group of event-handling methods from the  Container  class </li></ul><ul><li>The...
UI Components <ul><li>Swing supplies the following UI components (the class that implements each component is listed in pa...
Methods for UI Components <ul><li>add  </li></ul><ul><ul><li>Adds the specified Component </li></ul></ul><ul><li>remove  <...
Deploying Applets <ul><li>Deploying Applets on the Internet Versus an Intranet </li></ul><ul><ul><li>Use the  < applet >  ...
Practical Considerations <ul><li>Security Restrictions </li></ul><ul><ul><li>Applets cannot load libraries or define nativ...
… .recap <ul><li>What are Applets? </li></ul><ul><li>Architecture of Applets </li></ul><ul><li>Applets API </li></ul><ul><...
References <ul><li>“ Java 2 : The Complete Reference ”, Schildt, Herbert, TMH, 2001 </li></ul><ul><li>http://java.sun.com ...
Thank You
Upcoming SlideShare
Loading in …5
×

Applet Architecture - Introducing Java Applets

30,452 views

Published on

A back-to-basic presentation on Java applets

Published in: Technology, Art & Photos

Applet Architecture - Introducing Java Applets

  1. 1. Applet Architecture Amit Kumar Saha B.Tech. (3 rd year, Computer Science & Engineering ) College Roll No. 04/CS/20 Department of Computer Science & Informatics Haldia Institute of Technology Haldia Presenting Java Applets
  2. 2. What are Applets? <ul><li>” Applets are small applications that are accessed on an Internet Server, transported over the Internet, automatically installed,and run as part of a Web document” , ( Schildt , Herbert ”Java 2: The complete Reference,2001 )‏ </li></ul><ul><li>An applet is a program written in the Java programming language that can be included in an HTML page, much in the same way an image is included in a page. When you use a Java technology-enabled browser to view a page that contains an applet, the applet's code is transferred to your system and executed by the browser's Java Virtual Machine (JVM) ( http://java.sun.com/applets/ )‏ </li></ul>
  3. 3. Functional Diagram of Applets
  4. 4. Applet Architecture <ul><li>Event driven </li></ul><ul><ul><li>An applet waits until an event occurs. </li></ul></ul><ul><ul><li>The AWT notifies the applet about an event by calling event handler that has been provided by the applet.The applet takes appropriate action and then quickly return control to AWT </li></ul></ul><ul><ul><li>All Swing components descend from the AWT Container class </li></ul></ul><ul><li>User initiates interaction with an Applet ( and not the other way around ) </li></ul>
  5. 5. The Applet API <ul><li>The API is provided by the javax.swing.JApplet class and the java.applet.AppletContext interface. ( Java SE 6 ) </li></ul><ul><li>Applets can use these APIs to do the following: </li></ul><ul><ul><li>Be notified by the browser of milestones. </li></ul></ul><ul><ul><li>Load data files specified relative to the URL of the applet or the page in which it is running. </li></ul></ul><ul><ul><li>Make the browser display a document. </li></ul></ul><ul><ul><li>Find other applets running in the same page. </li></ul></ul><ul><ul><li>Play sounds. </li></ul></ul>
  6. 6. Life cycle of an Applet <ul><li>init : This method is intended for whatever initialization is needed for your applet. It is called after the param attributes of the applet tag. </li></ul><ul><li>start : This method is automatically called after init method. It is also called whenever user returns to the page containing the applet after visiting other pages. </li></ul><ul><li>stop : This method is automatically called whenever the user moves away from the page containing applets. You can use this method to stop an animation. </li></ul><ul><li>destroy : This method is only called when the browser shuts down normally </li></ul><ul><li>Thus, the applet can be initialized once and only once, started and stopped one or more times in its life, and destroyed once and only once. </li></ul>
  7. 7. Methods for Milestones <ul><li>Following is the interface for these methods: </li></ul><ul><li>public class Simple extends JApplet { </li></ul><ul><li>. . . </li></ul><ul><li>public void init() { . . . } </li></ul><ul><li>public void start() { . . . } </li></ul><ul><li>public void stop() { . . . } </li></ul><ul><li>public void destroy() { . . . } </li></ul><ul><li>. . . </li></ul><ul><li>} </li></ul><ul><li>Not every applet needs to override every one of these methods. Some very simple applets override none of them. </li></ul>
  8. 8. Applet Skeleton <ul><li>public class Simple extends JApplet { </li></ul><ul><li>. . . </li></ul><ul><li>public void init() { . . . } </li></ul><ul><li>public void start() { . . . } </li></ul><ul><li>public void stop() { . . . } </li></ul><ul><li>public void destroy() { . . . } </li></ul><ul><li>public void paint (Graphics g){.. } </li></ul><ul><li>. . . </li></ul><ul><li>} </li></ul><ul><li>In some situations the Applet may override the method update( ) </li></ul><ul><li>Applets do not need a main( ) method </li></ul><ul><li>Applets must be run under an applet viewer or a Java-compatible browser </li></ul><ul><li>User I/O is not accomplished with Java’s stream I/O classes. Instead, applets use the interface provided by the AWT </li></ul>
  9. 9. Program Execution Flow
  10. 10. Handling Events <ul><li>Applets inherit a group of event-handling methods from the Container class </li></ul><ul><li>The Container class defines several methods, such as processKeyEvent and processMouseEvent , for handling particular types of events, and then one catch-all method called processEvent </li></ul><ul><li>To react to an event, an applet must override the appropriate event-specific method </li></ul>
  11. 11. UI Components <ul><li>Swing supplies the following UI components (the class that implements each component is listed in parentheses): </li></ul><ul><li>Buttons (javax.swing.JButton ) </li></ul><ul><li>Checkboxes ( javax.swing.JCheckBox ) </li></ul><ul><li>Single-line text fields ( javax.swing.JTextField ) </li></ul><ul><li>Larger text display and editing areas ( javax.swing.JTextArea ) </li></ul><ul><li>Labels ( javax.swing.JLabel ) </li></ul><ul><li>Lists ( javax.swing.JList ) </li></ul><ul><li>Pop-ups ( javax.swing.Popup ) </li></ul><ul><li>Scrollbars ( javax.swing.JScrollBar ) </li></ul><ul><li>Sliders ( javax.swing.JSlider ) </li></ul><ul><li>Drawing areas ( java.awt.Canvas ) </li></ul><ul><li>Menus ( javax.swing.JMenu,javax.swing.JMenuBar javax.swing.JMenuItem, javax.swing.JCheckBoxMenuItem ) </li></ul><ul><li>Containers ( javax.swing.JPanel, javax.swing.JWindow and its subclasses) </li></ul>
  12. 12. Methods for UI Components <ul><li>add </li></ul><ul><ul><li>Adds the specified Component </li></ul></ul><ul><li>remove </li></ul><ul><ul><li>Removes the specified Component </li></ul></ul><ul><li>setLayout </li></ul><ul><ul><li>Sets the layout manager </li></ul></ul>
  13. 13. Deploying Applets <ul><li>Deploying Applets on the Internet Versus an Intranet </li></ul><ul><ul><li>Use the < applet > tag if the Web page is accessed through the Internet, or if it is accessed through an Intranet in which people use different browsers. </li></ul></ul><ul><ul><li>Use the < object > or < embed > tag if the Web page is accessed through an Intranet and you know which browser people use </li></ul></ul><ul><li>Deploying Applets for Specific Browsers </li></ul><ul><ul><li>For Internet Explorer only, use the < object > tag. </li></ul></ul><ul><ul><li>For the Mozilla family of browsers only, use the < embed > tag </li></ul></ul>
  14. 14. Practical Considerations <ul><li>Security Restrictions </li></ul><ul><ul><li>Applets cannot load libraries or define native methods. </li></ul></ul><ul><ul><li>An applet cannot start any program on the host that is executing it. </li></ul></ul><ul><ul><li>An applet cannot make network connections except to the host that it came from </li></ul></ul><ul><li>Threads in Applets </li></ul><ul><ul><li>Applets are generally multi-threaded – one thread builds up the UI while the other fetches data or does some background processing </li></ul></ul><ul><li>Working with a server-side application </li></ul>
  15. 15. … .recap <ul><li>What are Applets? </li></ul><ul><li>Architecture of Applets </li></ul><ul><li>Applets API </li></ul><ul><li>Deploying Applets </li></ul><ul><li>Applets & Security </li></ul>
  16. 16. References <ul><li>“ Java 2 : The Complete Reference ”, Schildt, Herbert, TMH, 2001 </li></ul><ul><li>http://java.sun.com </li></ul>
  17. 17. Thank You

×