Java: Applets and AWT - PowerPoint PPT Presentation

1 / 12
About This Presentation
Title:

Java: Applets and AWT

Description:

Abstract Windowing Toolkit. It contains classes for. Graphics (colors, fonts, images, ... Window. MSc Programme (Reading Jan 2001) Java: Applets and AWT ... – PowerPoint PPT presentation

Number of Views:105
Avg rating:3.0/5.0
Slides: 13
Provided by: itU99
Category:
Tags: awt | applets | java | windowing

less

Transcript and Presenter's Notes

Title: Java: Applets and AWT


1
Java Applets and AWT
Peter T. Breuer Universidad Carlos III de
Madrid ltptb_at_it.uc3m.esgt
2
Hierarchy
  • Object
  • Component
  • Container
  • Panel
  • Applet

java.lang
java.awt
java.applet
3
java.applet
  • public class Applet extends Panel
  • public abstract interface AppletContext
  • allows the applet to interact with the browser or
    viewer
  • public abstract interface AppletStub
  • internal interface
  • public abstract interface AudioClip
  • describes the methods and audio clip must have

4
Some applet methods
  • void init() called when applet is first loaded
  • void start() called when the applet becomes
    visible
  • void stop() called when applet becomes
    temporarily invisible
  • void destroy() called when applet is about to
    the unloaded

5
Some more applet methods
  • String getParameter(String name) gets a
    parameter from the html page
  • void showStatus(String msg) displays text in the
    status line
  • Image getImage(URL url) reads an image from the
    net
  • URL getCodeBase() returns the base URL from
    which the applet was called
  • any many others...

6
Some inherited methods
  • paint() called when the applet has to be drawn
    on the screen

7
Parameter passing
  • ltapplet code"x.class" width"10"
    height"10"gtltparam name"number"
    value"123"gtltparam name"image"
    value"img.gif"gtltparam name"sound"
    value"snd.au"gt lt/appletgt
  • String xgetParameter("number")

.html
.java
8
jar files
  • Command that allows to compress a numbers of
    files (like tar)
  • ltapplet archive"x.jar" code"x.class" width"10"
    height"10"gt ... lt/appletgt
  • The browser first searches for the needed file in
    the jar file, and if not found, tries to load the
    file as usual

9
Abstract Windowing Toolkit
  • It contains classes for
  • Graphics (colors, fonts, images, ...)
  • Components (buttons, menus, lists, ...)
  • Layout Managers (for the control of objects
    within container objects)

10
Graphics classes in AWT
  • Color
  • Cursor
  • Dimension
  • Font
  • FontMetrics
  • Graphics
  • Image
  • Insets
  • MediaTracker
  • Point
  • Polygon
  • PrintJob
  • Rectangle
  • Toolkit

11
Component classes in AWT
  • Component
  • Checkbox
  • Choice
  • List
  • Button
  • Canvas
  • Container
  • Label
  • ScrollBar
  • TextComponent
  • CheckboxGroup
  • MenuComponent
  • MenuShortcut

12
Layout classes in AWT
  • FlowLayout
  • GridLayout
  • GridBagConstraints
  • BorderLayout
  • CardLayout
  • GridBagLayout
Write a Comment
User Comments (0)
About PowerShow.com