Your SlideShare is downloading. ×
Applets_Basic Introduction
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

Applets_Basic Introduction

868

Published on

Java - An Introduction to Applets

Java - An Introduction to Applets

Published in: Education, Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
868
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
87
Comments
0
Likes
2
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
  • (Java Runtime Environment).
  • import java.awt.*; import java.applet.*; public class SimpleApplet extends Applet{ public void paint(Graphics g){ g.drawString("A Simple Applet", 20, 20); } }
  • Transcript

    • 1. Applets Internet Tools and Java Programming16/09/12 Applets 1
    • 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)16/09/12 Applets 2
    • 3. What are Applets?• 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 applets code is transferred to your system and executed by the browsers Java Virtual Machine (JVM) – (http://java.sun.com/applets/)16/09/12 Applets 3
    • 4. Applet• Applet is a Java program executed by a browser• The position of applets in software world is they occupy the client-side position in Web communication• On the server-side, another Java program comes, Servlets• Applets on client-side and servlets on server-side makes Java a truly "Internet-based language“ – http://way2java.com/applets/applets-vs-applications/16/09/12 Applets 4
    • 5. 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 normallyThus, 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.16/09/12 Applets 5
    • 6. Program Execution Flow To execute applets, the browsers come with JRE The browsers with Java loaded are known as Java enabled browsers16/09/12 Applets 6
    • 7. ILLUSTRATION16/09/12 Applets 7
    • 8. IMPORT STATEMENTS• Applets interact with user through AWT• Abstract Window Toolkit – Contains support for a window-based graphical interface• Applet Package – Contains the class Applet – Every applet created must be its subclass16/09/12 Applets 8
    • 9. CLASS, MEMBER FUNCTIONS• Simple Applet is declared as public. Why? – It is accessed by the code outside the program• paint() – Defined by AWT – Overridden by the applet16/09/12 Applets 9
    • 10. paint() and drawString()• Parameter – Graphic – Describes the graphics environment in which the applet is running• drawString() – Member of Graphics class – Outputs the string at a specified X,Y location16/09/12 Applets 10
    • 11. RUNNING AN APPLET• Executing an applet with a Java-compatible Web browser• Using an applet viewer – Executes in a window – Fastest & Easiest way16/09/12 Applets 11
    • 12. Web browser• Write a short HTML• Dimensions of display area• Execute your browser and then load this file HTML file16/09/12 Applets 12
    • 13. APPLET VIEWER• Include the HTML code as comments• Documented with necessary type of HTML statements16/09/12 Applets 13
    • 14. APPLICATION vs. APPLET16/09/12 Applets 14
    • 15. ADVANTAGES OF APPLETS• Deployment of applets is easy in a Web browser and does not require any installation procedure in real time programming• Writing and displaying (just opening in a browser) graphics and animations is easier than applications• In GUI development, constructor, size of frame, window closing code etc. are not required (but are required in applications)16/09/12 Applets 15
    • 16. RESTRICTIONS• Applets require a compiler to compile and also a browser to execute.• In realtime environment, the bytecode of applet is to be downloaded from the server to the client machine• Applets are treated as untrusted and for this reason they are not allowed, as a security measure, to access any system resources like file system etc. available on the client system• Code can be developed to communicate between applets using AppletContext16/09/12 Applets 16
    • 17. What Applet cant do – Security Limitations• Applets are treated as untrusted because they are developed by somebody and placed on some unknown Web server• When downloaded, they may harm the system resources or steal passwords and valuable information.• As applets are untrusted, the browsers come with many security restrictions. Security policies are browser dependent.• Browser does not allow the applet to access any of the system resources.16/09/12 Applets 17
    • 18. LIMITATIONS• Applets are not permitted to use any system resources like file system as they are un trusted and can inject virus into the system• Applets cannot read from or write to hard disk files.• The JRE throws SecurityException if the applet violates the browser restrictions16/09/12 Applets 18
    • 19. KEY POINTS16/09/12 Applets 19
    • 20. REFERENCES• “Java : The Complete Reference”, Schildt, Herbert, TMH, 7th Edition, 2007• http://way2java.com/applets/applets-vs- applications• http://java.sun.com16/09/12 Applets 20
    • 21. Thank You16/09/12 Applets 21

    ×