Introduction to Java Applets - PowerPoint PPT Presentation

1 / 12
About This Presentation
Title:

Introduction to Java Applets

Description:

Applet is a Java program designed to be run by a web browser or applet viewer ... Provide user interface (GUIs) More than just banners, logos, and picts ... – PowerPoint PPT presentation

Number of Views:27
Avg rating:3.0/5.0
Slides: 13
Provided by: qata
Category:

less

Transcript and Presenter's Notes

Title: Introduction to Java Applets


1
Introduction to Java Applets
  • Understanding Applets
  • Editing, and Running Applets

2
Introduction
  • Why Java?
  • current
  • portable
  • Applets and Applications

3
Why Object-Oriented Programming?
  • Encapsulation (modeling)
  • keeps data and its behavior together
  • allows to create models (classes)
  • Inheritance (reusability)
  • allows to reuse code
  • Java API

4
Reading an Applet
  • In Java we can create Applications or Applets
  • Applet is a Java program designed to be run by a
    web browser or applet viewer
  • Application is a stand alone Java program which
    runs from the console window

5
Java Applets
  • Provide user interface (GUIs)
  • More than just banners, logos, and picts
  • They need a browser to run
  • Machine independent

6
Components of an applet
  • Comments
  • Import statements
  • packages
  • classes
  • Class Definition
  • public
  • private, protected
  • class
  • Hello
  • extends Applet
  • inheritance

7
Components of an applet - cont.
  • Body of the class
  • Methods and Methods Definitions
  • data
  • methods
  • public void paint(Graphics g)
  • g.drawString(Hello, 30 , 30)
  • calling a method
  • parameters
  • g.drawRectangle(20, 5, 140, 50)

8
Running an Applet
  • Using CodeWarrior
  • Save the source file (.java) with the same name
    as the name of the class.
  • Then, edit the TrivialApplet.html file
  • Make sure to change the name of the .class file
    under code
  • The name of your source file the name of the
    Java class are important. They both should have
    the same name!

9
Finding and Fixing Errors
  • Syntax errors
  • execution (logical) errors
  • BE PATIENT!
  • IMPLEMENT AND TEST!

10
A second look at Applets
  • Keywords
  • Look up a list of all Java reserved words
  • Identifiers
  • Look up Java naming conventions
  • Statements
  • semicolons
  • Applet Window
  • dimensions
  • Java Graphics Class
  • Look up a brief description of this class

11
Graphics in Java
  • The AWT includes a Graphics Class
  • What does AWT mean?
  • http//java.sun.com/j2se/1.4/docs/api/index.html/
  • live by this site!

12
Homework
  • readings
  • Chapter 2
  • Start thinking about Lab02 due Sunday Sept. 11th
  • Lab01 is due Thursday by 800am
  • Check Exercise-01.doc
Write a Comment
User Comments (0)
About PowerShow.com