Chapter 16: Events


Overview

Now you know how to create components and lay them out in a GUI. The next step is to learn about events, which are the mechanism by which components inform us that they have been used.

A component that does not send events is like a doorbell that does not ring. It looks okay, but it can't make anything happen. It has look but no feel. In this chapter, you will learn how to make components responsive. This will prepare you for Chapter 17, "Final Project," where you will observe in detail a Java application that uses painting, components, events, and all the other programming techniques presented in this book.

Java's original event mechanism was quite limited. It was designed back when it was believed that Java would mostly be used to create applets on Web pages, where space would be limited and GUIs would be simple. It soon became evident, however, that Java was an excellent programming language for domains that had nothing to do with Web pages. As non-Web-based Java applications propagated, GUIs became more complicated, and the current event mechanism was introduced in release 1.1.

The new mechanism is scalable, which means it is useful and efficient over a broad range of complexity, from very elementary GUIs to extremely intricate ones. This comes at a price. The event mechanism is not simple. It isn't horribly complicated, but it does consist of several interacting pieces, and it might not make sense until you have seen all the pieces. But hang in there. It will all make sense soon, and when it does, you will have a powerful tool for creating full-fledged GUIs that have both look and feel.




Ground-Up Java
Ground-Up Java
ISBN: 0782141900
EAN: 2147483647
Year: 2005
Pages: 157
Authors: Philip Heller

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net