Your SlideShare is downloading. ×
Applet Architecture - Introducing Java Applets
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

Applet Architecture - Introducing Java Applets

19,099
views

Published on

A back-to-basic presentation on Java applets

A back-to-basic presentation on Java applets

Published in: Technology, Art & Photos

2 Comments
3 Likes
Statistics
Notes
No Downloads
Views
Total Views
19,099
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
682
Comments
2
Likes
3
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 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. What are Applets?
    • ” 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 )‏
    • 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/ )‏
  • 3. Functional Diagram of Applets
  • 4. Applet Architecture
    • Event driven
      • An applet waits until an event occurs.
      • 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
      • All Swing components descend from the AWT Container class
    • User initiates interaction with an Applet ( and not the other way around )
  • 5. The Applet API
    • The API is provided by the javax.swing.JApplet class and the java.applet.AppletContext interface. ( Java SE 6 )
    • Applets can use these APIs to do the following:
      • Be notified by the browser of milestones.
      • Load data files specified relative to the URL of the applet or the page in which it is running.
      • Make the browser display a document.
      • Find other applets running in the same page.
      • Play sounds.
  • 6. Life cycle of an Applet
    • init : This method is intended for whatever initialization is needed for your applet. It is called after the param attributes of the applet tag.
    • 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.
    • 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.
    • destroy : This method is only called when the browser shuts down normally
    • 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.
  • 7. Methods for Milestones
    • Following is the interface for these methods:
    • public class Simple extends JApplet {
    • . . .
    • public void init() { . . . }
    • public void start() { . . . }
    • public void stop() { . . . }
    • public void destroy() { . . . }
    • . . .
    • }
    • Not every applet needs to override every one of these methods. Some very simple applets override none of them.
  • 8. Applet Skeleton
    • public class Simple extends JApplet {
    • . . .
    • public void init() { . . . }
    • public void start() { . . . }
    • public void stop() { . . . }
    • public void destroy() { . . . }
    • public void paint (Graphics g){.. }
    • . . .
    • }
    • In some situations the Applet may override the method update( )
    • Applets do not need a main( ) method
    • Applets must be run under an applet viewer or a Java-compatible browser
    • User I/O is not accomplished with Java’s stream I/O classes. Instead, applets use the interface provided by the AWT
  • 9. Program Execution Flow
  • 10. Handling Events
    • Applets inherit a group of event-handling methods from the Container class
    • 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
    • To react to an event, an applet must override the appropriate event-specific method
  • 11. UI Components
    • Swing supplies the following UI components (the class that implements each component is listed in parentheses):
    • Buttons (javax.swing.JButton )
    • Checkboxes ( javax.swing.JCheckBox )
    • Single-line text fields ( javax.swing.JTextField )
    • Larger text display and editing areas ( javax.swing.JTextArea )
    • Labels ( javax.swing.JLabel )
    • Lists ( javax.swing.JList )
    • Pop-ups ( javax.swing.Popup )
    • Scrollbars ( javax.swing.JScrollBar )
    • Sliders ( javax.swing.JSlider )
    • Drawing areas ( java.awt.Canvas )
    • Menus ( javax.swing.JMenu,javax.swing.JMenuBar javax.swing.JMenuItem, javax.swing.JCheckBoxMenuItem )
    • Containers ( javax.swing.JPanel, javax.swing.JWindow and its subclasses)
  • 12. Methods for UI Components
    • add
      • Adds the specified Component
    • remove
      • Removes the specified Component
    • setLayout
      • Sets the layout manager
  • 13. Deploying Applets
    • Deploying Applets on the Internet Versus an Intranet
      • 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.
      • Use the < object > or < embed > tag if the Web page is accessed through an Intranet and you know which browser people use
    • Deploying Applets for Specific Browsers
      • For Internet Explorer only, use the < object > tag.
      • For the Mozilla family of browsers only, use the < embed > tag
  • 14. Practical Considerations
    • Security Restrictions
      • Applets cannot load libraries or define native methods.
      • An applet cannot start any program on the host that is executing it.
      • An applet cannot make network connections except to the host that it came from
    • Threads in Applets
      • Applets are generally multi-threaded – one thread builds up the UI while the other fetches data or does some background processing
    • Working with a server-side application
  • 15. … .recap
    • What are Applets?
    • Architecture of Applets
    • Applets API
    • Deploying Applets
    • Applets & Security
  • 16. References
    • “ Java 2 : The Complete Reference ”, Schildt, Herbert, TMH, 2001
    • http://java.sun.com
  • 17. Thank You