Event Handling In Java Part II (
Page 1 of 6 )
With the skills that you have developed so far from Part I of the tutorial, you can design a graphical user interface with beauty and easy. Let us refresh ourselves before we proceed, Events are method calls that Javas windowing system performs whenever any element of a user interface is manipulated.With the skills that you have developed so far from Part I of the tutorial, you
can design a graphical user interface with beauty and easy. Let us refresh
ourselves before we proceed,
Events are method calls that Java's
windowing system performs whenever any element of a user interface is
manipulated. Java events are part of the Java AWT (Abstract Windowing Toolkit)
package. An event is the way that Java communicates to you, as the programmer,
and to other Java AWT components that
somethinghas happened. That
“something” can be an input from the user (like button or mouse clicks,
keypress), changes in the system environment (a window closing, opening or
window being scrolled up or down), or a host of other things that might, in some
way, affect the operation of the program.
To sum it up every time the
user types a character or pushes a mouse button, an event occurs. Any object can
be notified of the event. All it has to do is implement the appropriate
interface and be registered as an
event listener on the appropriate
event source. Swing components can generate many kinds of events. We have
covered a wide variety of these events like action event, mouse event, and
keypress event and Event-Listeners like actionListener, mouseListener, and
keyListener earlier. Today we will be taking a much closer look into Explicit
Event-Handling and Adapters.