Introduction to Java Applets: Core Concepts and Implementation

topic applet n.w
1 / 23
Embed
Share

Explore the world of Java applets with this comprehensive overview covering topics such as different applet types, building applet code, and the structure of an applet. Learn how to write and incorporate applets into web pages, distinguish between local and remote applets, and understand the differences between applets and applications. Prepare yourself to create engaging applets by following the steps outlined in the process of writing applets.

  • Java Applets
  • Core Concepts
  • Implementation
  • Web Development

Uploaded on | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. Topic Applet Presented by Thatte R. B. Department of Comp. Sci. & IT. Deogiri College, Aurangabad

  2. Applet CORE JAVA-II

  3. Introduction to Applet

  4. Applet Types - Local Applets Local Applets We can write our own applets and embed them into web page. As the applet is available to local system , to locate and load it no internet connection is required. Local Applet Local computer Loading Local Applets

  5. Applet Types - Remote Applet Remote Applet - We can use remote applet to embed them into web page. As the applet is available on to remote system on internet, to locate and load it internet connection is required. Remote Computer (Server) Local Computer (Client) Internet Remote Applet Loading Remote Applets

  6. Applets Vs Application Applets do not use the main() method for initiating execution of the code. Applets when loaded automatically call certain methods to start and execute the applet. Applets can not be run independently. They are run from inside the a web page using HTML tag. Applets can nor read from or write the files in the local computer. Applets can not communicate with other servers on the network. Applet can not run any program from the local computer Applets are restricted from using libraries from other languages such as c/c++

  7. Preparing to write Applets (Steps) Building an applet code (.java file) Creating an executable applet (.class file) Designing an web page using HTML tags Preparing <APPLET> tag. Incorporating <APPLET> tag into the web page. Creating HTML file. Testing the applet code

  8. Building Applet Code Our applet code uses the services of two different classes Applet and Graphics from the java class libraries. Applet class provides life and behavior to our applet. paint() method of Applet class displays result on screen. The output may display graphics ,sound or text. The paint() method uses Graphics object

  9. Structure Of Applet import java.applet.Applet; import java.awt.*; -------------------- --------------------- public class AppletClassname extends Applet { ------------------------- --------------------------- public void paint(Graphics g) { ---------------- //.awt Abstract Windows Toolkit } } ------------------ // Applet operations code -------------------

  10. Chain of classes inherited by applet class Java.lang.Object Java.awt.Component Java.awt.Container Java.awt.Panel Java.applet.Applet

  11. Applet Life Cycle

  12. Applet Tag <APPLET CODE=HELLOJAVA.CLASS WIDTH=400 HEIGHT=200 > </APPLET>

  13. Adding Applet to HTML file Example

  14. Running The Applet example We must have the following files in our directory 1. HelloJava.java 2. HelloJava.class 3. HelloJava.html To run an applet , we require one of the following tools 1. Java-enabled browser (such as HotJava or Netscape) 2. Java appletviewer

  15. Java-enabled browser, able to see entire web page containts Appletviwer can display only applet , not full flaged browser. The appletviwer is a part of Java Development Kit (JDK) We can use it as follows appletviwer HelloJava.html

  16. Lets see the DEMO

  17. More about Applet tag <APPLET > [ < PARAM NAME = name1 VALUE = value1 > ] [ < PARAM NAME = name1 VALUE = value1 > ] -------------- [ Text to be displayed in the absence of Java] < /APPLET > [ CODEBASE=codebase_URL ] CODE = AppletFileName.class [ ALT = alternate_text ] [ NAME = applet_instance_name ] WIDTH = pixels HEIGHT = pixels [ ALLIGN] [ VSPACE ] [ HSPACE ]

  18. Passing parameters to applet Example

  19. Introduction The internet required secure, platform independent programs which should be easily transported from one machine on the network to another. Since java programs are compiled into an intermediate bytecode which are very small in size they can be easily stored and transmitted across the network. Such programs are called applets. All basic OOP and GUI concepts apply to applets as well. There is a difference between application and applets

  20. Creating applets Applications are stand-alone, independent programs which are executed under the control of the operating system of the computer. Applets are java programs to be transmitted over the internet and executed by a java compatible web browser. Applets are powerful tool for client-side programming. Applets are not executed by the console-based java run-time interpreter. Rather, they are executed by either a web browser or an applet viwer.

  21. The Applet Framework Java provides programmers with standard framework, providing set of classes. A programmer can then customize the behavior as required by inheriting from the application class and overriding the methods of interest. In a typical program, the programmer decides the order in which the methods will be invoked. However, in the case of applet the framework s default control mechanism will decide which overridden method should be invoked at the appropriate time, called inversion of control. Programmer has no control over the order in which the methods will be invoked. An applet uses an applet framework The order in which applet methods will be invoked is predefined.

More Related Content