Chapter 15

Responding to Keystrokes and Mouse Clicks

In This Chapter

arrow Creating code to handle mouse clicks (and other such events)

arrow Writing and using a Java interface

In the late 1980s, I bought my first mouse. I paid $100 and, because I didn’t really need a mouse, I checked with my wife before buying it. (At the time, my computer ran a hybrid text/windowed environment. Anything that I could do with a mouse, I could just as easily do with the Alt key.)

Now it’s the 21st century. The last ten mice that I got were free. Ordinary ones just fall into my lap somehow. A few exotic mice were on sale at the local computer superstore. One cost $10 and came with a $10 rebate.

As I write this chapter, I’m using the most recent addition to my collection — an official For Dummies mouse. This yellow and white beauty has a little compartment filled with water. Instead of a snowy Atlantic City scene, the water surrounds a tiny Dummies Man charm. It’s so cute. It was a present from the folks at Wiley Publishing.

Go On … Click That Button

In previous chapters, I create windows that don’t do much. A typical window displays some information but doesn’t have any interactive elements. Well, the time has come to change all that. This chapter’s first example is a window with a button on it. When the user ...

Get Java For Dummies, 6th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.