G6DICP - Lecture 17 - PowerPoint PPT Presentation

1 / 6
About This Presentation
Title:

G6DICP - Lecture 17

Description:

G6DICP - Lecture 17 GUI (Graphical User Interface) Programming Java GUI Class Libraries AWT Abstract Windows Toolkit Small and relatively simple GUI library ... – PowerPoint PPT presentation

Number of Views:56
Avg rating:3.0/5.0
Slides: 7
Provided by: TimBrai
Category:
Tags: g6dicp | lecture

less

Transcript and Presenter's Notes

Title: G6DICP - Lecture 17


1
G6DICP - Lecture 17
  • GUI (Graphical User Interface) Programming

2
Java GUI Class Libraries
  • AWT Abstract Windows Toolkit
  • Small and relatively simple GUI library
  • Bundled with JDK 1.0
  • Major revisions in JDK 1.1 (not compatible with
    1.0)
  • No fundamental changes since JDK 1.2 (Java 2)
  • Swing Java Foundation Classes
  • Large GUI library essentially a superset of AWT
  • The Swing Set
  • Compatible with JDK 1.1 (not included)
  • Bundled with Java 2
  • Swing and AWT are similar in principle, but Swing
    is very much larger both in terms of number of
    classes and methods.

3
Major GUI concepts
  • Windows
  • Containers
  • Components
  • Events

4
The Java Frame class
  • java.awt.Frame
  • Frame objects represent windows
  • Graphical programs (almost) always have at least
    one Frame
  • Rarely used directly usually subclassed
  • Invoking the show() method causes window to be
    displayed
  • The constructor of a Frame is usually where
    initialisation code is placed (and often most of
    the layout/UI of a graphical program)

5
The Paint Method
  • java.awt.Frame.paint(Graphic g)
  • Executed automatically whenever the screen is
    redrawn
  • Overriden to contain code that writes to the
    screen
  • Be careful
  • Avoid accidental recursion
  • The paint method should never be invoked directly
  • Since paint is executed every time the screen is
    redrawn do not do anything time consuming in
    it, e.g.
  • File i/o
  • Large loops or recursion
  • Complex calculations

6
The Graphic Class
  • java.awt.Graphic
  • Abstract class containing various drawing methods
  • Never instantiated in code
  • Instantiated by the VM, and an instance passed
    into the paint() method
  • Methods of this instance are used to write onto
    the screen
Write a Comment
User Comments (0)
About PowerShow.com