Applets - PowerPoint PPT Presentation

1 / 9
About This Presentation
Title:

Applets

Description:

Called after init and when the user browses back to the applet. public void paint(Graphics g) ... destroy and when the user browses away from the applet. public ... – PowerPoint PPT presentation

Number of Views:42
Avg rating:3.0/5.0
Slides: 10
Provided by: rob1125
Category:
Tags: applets | browses

less

Transcript and Presenter's Notes

Title: Applets


1
Applets
  • Robert Salkin
  • CSI 205 OOP using Java
  • Summer 2005, 6W1

2
Quick Review
  • Swing Components usually are lightweight and
    start with J.
  • GUI Components are put into Containers.
  • A Container is also a Component, so a Container
    can be put (add) into another Container.

3
Quick Review
  • Graphics objects handle the graphics context, in
    which shapes can be drawn.
  • Methods starting with fill draw filled shapes,
    while draw methods draw unfilled shapes, or
    outlines of shapes.
  • paintComponent is the method that should be
    overridden, while repaint should be called when a
    repaint of the screen should be done.

4
Applets
  • Applets are compiled classes that extend JApplet.
  • An HTML page with APPLET tags is required to view
    an applet online via a browser or appletviewer.
  • ltAPPLET CODEMyClassName.class WIDTHw
    HEIGHThgtlt/APPLETgt

5
Methods
  • There are 5 methods that may be overridden in an
    applet a main method is irrelevant.
  • public void init()
  • Called once after applet is loaded.
  • public void start()
  • Called after init and when the user browses back
    to the applet.
  • public void paint(Graphics g)
  • Called after start and after the window is
    uncovered.
  • public void stop()
  • Called before destroy and when the user browses
    away from the applet.
  • public void destroy()
  • Called when the browser is quit entirely.

6
Application to Applet
  • Not much needs to be done to convert an
    application to an applet.
  • main logic needs to be moved into start and/or
    paint.
  • The main method isnt useful to the applet.
  • Constructor operations should be moved into init.
  • Most GUI operation stays the same.
  • The class is instantiated by the mechanism that
    runs the applet, so do not instantiate yourself.

7
Security
  • Applets are generally not allowed to interact
    with the local systems resources or do risky
    things.
  • Cant save/load files.
  • Cant connect to other IPs.
  • A signed applet may be allowed to access the
    local disks and do other risky things.

8
Final Exam
  • Longer than the Midterm.
  • Open book/notes.
  • Computers may be used ONLY for checking files on
    the class website.
  • NO compiling/googling/etc.
  • Visiting other websites will result in a failure
    for the exam.
  • Answers will be written on an answer sheet.
  • Less emphasis on graphics/applets, but at
    minimum, you will need to write an applet, with
    HTML, to draw a fairly simple object on the
    screen worth 15 pts of the exam.
  • There will be multiple choice, short answer,
    whats wrong with the code, and writing your own
    code.

9
Review
  • May be heavily emphasized
  • If/else
  • Switch
  • Loops
  • Methods
  • Classes/objects
  • Inheritance
  • Polymorphism
  • GUI
  • Arrays
  • Searching/sorting/randomizing
  • May be on the test, but with less emphasis
  • Files
  • Graphics
  • Applets
Write a Comment
User Comments (0)
About PowerShow.com