CHAPTER 4

image

Button Up! Using Buttons and Labels

Up to this point, the applications you built in this book have been kind of boring.1 They really haven’t done anything except display a message. But now it’s time to change that. In this chapter, you’re going to add a button to your application and then have it react when the user presses it. How does that sound?

To do this you’ll first take a look at the JButton class hierarchy and see the Java way to create a button and add it to the application frame. Then you’ll see a verbose way, in Jython, to do the same thing. Then you’ll see a more concise way to put a button on the frame and have an event ...

Get Swing for Jython: Graphical Jython UI and Scripts Development using Java Swing and WebSphere Application Server now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.