slide1
Download
Skip this Video
Download Presentation
CIS3023: Programming Fundamentals for CIS Majors II Summer 2010

Loading in 2 Seconds...

play fullscreen
1 / 13

CIS3023: Programming Fundamentals for CIS Majors II Summer 2010 - PowerPoint PPT Presentation


  • 87 Views
  • Uploaded on

CIS3023: Programming Fundamentals for CIS Majors II Summer 2010. Introduction to Applets. Course Lecture Slides 29 th July 2010. Ganesh Viswanathan. Applets.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'CIS3023: Programming Fundamentals for CIS Majors II Summer 2010' - damisi


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
slide1
CIS3023: Programming Fundamentals for CIS Majors II

Summer 2010

Introduction to Applets

Course Lecture Slides29thJuly 2010

GaneshViswanathan

applets
Applets
  • Applets are small applications accessed on an Internet server, transported over the networks, automatically installed and run as part of a web document.
  • At the client, applets get limited access to resources to be able to produce graphics, multimedia UI, run computations, etc. without risk of viruses or breaching data integrity.
applets1
Applets
  • Applet Code Example: HelloWorld.java

import java.awt.Graphics;

import java.applet.Applet;

public class HelloWorldextendsApplet{

public void paint(Graphics g){

g.drawString("Hello World!", 120, 80);

}

}

Every applet must be a subclass of Applet.

applets2
Applets
  • Web document: HelloWorld.html

Applet example

abstract window toolkit awt
Abstract Window Toolkit (AWT)
  • The Abstract Window Toolkit (AWT) is Java's original platform-independent windowing, graphics, and user-interface widget toolkit.
  • Applets interact with the user through the AWT, not through the console-based I/O classes.
  • AWT is a part of Java Foundation Classes (JFC),the standard API for providing a graphical user interface (GUI) for a Java program.
abstract window toolkit awt1
Abstract Window Toolkit (AWT)
  • AWT contains support for a window-based, graphical interface.
  • AWT supports graphics through components (visible UI elements-buttons/ labels/ textfields) and containers (components that contain and organize other components).
  • All containers inherit from the java.awt.Container base class, which itself inherits from java.awt.Component
applets3
Applets
  • Do not have main() method
  • Instead applet begins execution when the name of its class is passed to an applet viewer or to a network browser.
  • Compile the applet in the same way as a normal java application)
  • In the example, the paint() method defined by AWT and overridden by the applet helps to redraw output on screen.
applets4
Applets
  • Applets are event-driven.
  • User initiates interaction with an applet. These interactions are sent to the applet as “events” to which the applet must respond.
  • Example: When the user clicks on a button in the applet window, a button-click event is generated.
applets5
Applets
  • In your applet override a set of methods that help the browser or applet-viewer to interface to the applet and control its execution.
  • Applet class defines – init(), start(), stop(), destroy()
  • AWT Component class defines paint() method.
applet skeleton
Applet Skeleton
  • import java.awt.*;
  • import java.applet.*;
  • public class MyAppletSkeleton extends Applet {
  • // browser calls init when applet is first loaded
  • public void init( ){ /* initialization */ }
  • // called second, after init. Also called whenever applet is restarted
  • public void start( ){ /* start or resume execution */ }
  • //called when the applet is stopped
  • public void stop( ){ /* suspends execution */ }
  • //called when applet is terminated. Last method executed
  • public void destroy( ){ /* perform shutdown operations */ }
  • //called when an applet’s window must be restored (redrawn)
  • public void paint(Graphics g){ /* redisplay contents of window */ }
  • }
applet skeleton1
Applet Skeleton
  • import java.awt.*;
  • import java.applet.*;
  • public class MyAppletSkeleton extends Applet {
  • // browser calls init when applet is first loaded
  • public void init( ){ /* initialization */ }
  • // called second, after init. Also called whenever applet is restarted.
  • public void start( ){ /* start or resume execution */ }
  • //called when the applet is stopped.
  • public void stop( ){ /* suspends execution */ }
  • //called when applet is terminated. Last method executed.
  • public void destroy( ){ /* perform shutdown operations */ }
  • //called when an applet’s window must be restored (redrawn)
  • public void paint(Graphics g){ /* redisplay contents of window */ }
  • }
applets6
Applets
  • Further examples.
get more info
Get more info!
  • Java docs: java.applet
  • http://download-llnw.oracle.com/javase/1.5.0/docs/api/java/applet/package-summary.html
  • Java docs: java.awt http://java.sun.com/j2se/1.5.0/docs/api/java/awt/package-summary.html
  • http://java.sun.com/products/jdk/awt/#what
  • JFC
  • http://docstore.mik.ua/orelly/java-ent/jfc/ch02_04.htm#jfcnut-ch-2-tab-awtcont
ad