Home : Course Map : Chapter 7 : Java :
Events Overview
JavaTech
Course Map
Chapter 7

Introduction
Event Overview
Event Processing
Button Events
  Demo 1
 Demo 2
Mouse Events
  Demo3

More Components
  Demo 4  Demo 5
  Demo 6  Demo 7

LayoutManagers-1
  Demo 8     Demo 9
  Demo 10  Demo 11
  Demo 12

LayoutManagers-2
  Demo 13  Demo 14
  Demo 15  Demo 16
  Demo 17

Inner Classes
Anonymous Class
Adapter Classes
  Demo 18  Demo 19
Frames & Menus
  Demo 20  Demo 21
Exercises

    Supplements
AWT Components
  Button
     Demo 1
  Canvas
     Demo 2
  AWT GUI Demo
     Demo 3
Swing Dialogs
JOptionPane Dialog
  Demo 1
JDialog
  Demo 2
UI Enhancement: P1
  Demo 1   Demo 2
  Demo 3

UI Enhancement: P2
  Demo 1
     About JavaTech
     Codes List
     Exercises
     Feedback
     References
     Resources
     Tips
     Topic Index
     Course Guide
     What's New

Graphical user interfaces (GUI) offers a profoundly different programming environment than the step-by-step, linear world of procedural programs.

The GUI presents many features all appearing to operate independently and in parallel, even though usually run with a single processor. GUIs match well with the modularity of object oriented languages since the many different parts of a GUI can be created as class objects.

In the procedural world, the user simply starts a program and waits for it to churn through its algorithm and eventually reach the end and stop. In the GUI enviroment, the program instead waits for the user to select some task and then it carries out that selected action. Afterwards, the program returns to a waiting state. (Meanwhile, the processor, which could be physical or a Virtual Machine, will switch frequently to other tasks.)

This wait state could involve a loop that checks a flag each pass or a sleep state that is interrupted by the OS, or in the case of Java, by the JVM. When the user moves a mouse, clicks one of its buttons, hits a key, or initiates some other signal, the operating system detects this and passes the information to the JVM, which creates an event object to carry information about the event to the program.

In version 1.0 of Java, when a mouse clicked over a button, the event first went to the event handling code of the lowest level container and then up through all the sub-components until one of them dealt with the event. Only subclasses of the Component class could handle events.

In version 1.1 came a more flexible and less wasteful event handling system in which events are sent just to those components that register to receive such events.

The event registering scheme also allows for custom components, such as those in Swing. A customized visual component can ask to have relevant events sent to it just like any other component. Also, a class this not a Component subclass can implement the handling (or listener) interface for a particular type of event, such as a button press.

 

           Tech
Histogram UI
  Demo 1
Probablity Distrib.
  Demo 2 Demo 3
RejectionMethod
Histogram Stats
  Demo 4
Exercises

           Physics
Sim & Randomness
Custom Prob. Dist.
   Demo 1
Histogram Dist.
   Demo 2
Monte Carlo
  Demo 3
Exercises

  Part I Part II Part III
Java Core 1  2  3  4  5  6  7  8  9  10  11  12 13 14 15 16 17
18 19 20
21
22 23 24
Supplements

1  2  3  4  5  6  7  8  9  10  11  12

Tech 1  2  3  4  5  6  7  8  9  10  11  12
Physics 1  2  3  4  5  6  7  8  9  10  11  12

Java is a trademark of Sun Microsystems, Inc.