Applets - PowerPoint PPT Presentation

About This Presentation
Title:

Applets

Description:

Applets Design of Applets Design of Applets Sun wrote Java to be executable within a hosting application browser The applications are applets. – PowerPoint PPT presentation

Number of Views:52
Avg rating:3.0/5.0
Slides: 11
Provided by: facultyKu
Category:
Tags: applets | java

less

Transcript and Presenter's Notes

Title: Applets


1
Applets
2
Applets
  • Design of Applets

3
Design of Applets
  • Sun wrote Java to be executable within a hosting
    application
  • browser
  • The applications are applets.
  • An applet is downloaded to the local client
    application and run on the local java-enabled
    machine
  • All ordinary capability except file output and
    database input or output is easily available

4
Design of Applets
  • An Applet is run inside of another application
  • Browser
  • AppletViewer
  • The programmer adds panels with their controls to
    browsers content panel (the web page)

5
Design of Applets
  • There are five major methods in an Applet
  • init () called when Applet starts
  • start () called when page is displayed
  • stop () called when user exits
  • destroy () called when resources are lost
  • paint () called when Applet is refreshed

6
Design of Applets
  • Sample codepublic class Program4 extends
    JApplet
  • public void init ()
  • getContentPane ( ).add(myPanel)
  • Where myPanel is the one of the panels containing
    controls

7
Design of Applets
  • Design of Hosting Web Page (use of Applet tag)
  • ltbodygt
  • ltapplet codemyservlets.AdderApplet.class
  • width550 height400gt
  • ltparam namehost value
  • "http//localhost8080/user002/servlet/myservlet
    s.AdderServlet"gt
  • lt/appletgt
  • lt/bodygt
  • Where host is an argument sent to the Applet from
    the web page

8
GUI Applications
  • Using a frame
  • public class Example extends JFrame
  • public Example ( )
  • getContentPane( ).add(myPanel)
  • public static void main (String args )
  • Example example new Example (Example)
  • example.setTitle (aTitle)
  • example.setSize (300, 250)
  • example.setDefaultCloseOperation (3)
  • example.setVisible(true)

9
GUI Application as Applet
  • Init and handle events
  • public class Example extends JApplet
  • public void init ( )
  • getContentPane( ).add(myPanel)
  • setTitle (aTitle)
  • setSize (300, 250)
  • setDefaultCloseOperation (3)
  • setVisible(true)
  • See ConvertTemperatures applet, and note change
    from application

10
Summary
  • Applets are a window system
  • One can also place windows in a frame and use
    them in an application
  • Applets significantly bring web-based
    applications to life by moving the work to the
    client machine
  • Error checking can be decentralized from the
    server to the clients
Write a Comment
User Comments (0)
About PowerShow.com