O'Reilly logo

Java™ After Hours: 10 Projects You'll Never Do at Work by Steven Holzner

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

Working with SWT Events

Take a look at the example in Figure 8.3, ButtonProject.java, which is designed to show how to handle events in SWT applications. When you click the button in this project, the application catches that event and then the message “Thanks for clicking.” appears in the Text widget.

Figure 8.3. Handling events in SWT applications.

This application starts by creating the Button widget it needs, giving it the caption “Click here,” and making it a push button (the allowed styles are SWT.ARROW, SWT.CHECK, SWT.PUSH, SWT.RADIO, SWT.TOGGLE, SWT.FLAT, SWT.UP, SWT.DOWN, SWT.LEFT, SWT.RIGHT, and SWT.CENTER):

 import org.eclipse.swt.*; ...

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