O'Reilly logo

NetBeans IDE 8 Cookbook by Rhawi Dantas, David Salter

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Responding to events

So far, we've designed a Swing desktop application. We've added some controls onto a form, added a menu system, and added a toolbar. At the moment, there's no functionality behind the controls and menu items.

The next step after designing a Swing desktop application is to add behaviors to it.

In Swing, this is done by implementing event listeners. Firstly, we must register specific objects, the event listeners, onto Swing components in order to perform a determined task. When an event is triggered, the Swing component passes this to the listeners to handle the action according to what was implemented.

There are multiple kinds of events in Swing that include mouse, focus, key, and window events.

For a more detailed view of event ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required