S
●
Use JButton
●
Work with JTextField
●
Create a JCheckBox
●
Work with JList
●
Use anonymous inner classes or lambda expressions to handle events
o far, all of the programs in this book have been consolebased. This means that they do
not make use of a graphical user interface (GUI). Although consolebased programs are
excellent for teaching the basics of Java and for some types of programs, such as server
side code, most realworld client applications will be GUIbased. At the time of this
writing, the most widely used Java GUI is Swing.
Swing defines a collection of classes and interfaces that support a rich set of visual
components, such as buttons, text fields, scroll panes, check boxes, trees, and tables, to
name a few. Collectively, these controls can be used to construct powerful, yet easyto
use graphical interfaces. Because of its widespread use, Swing is something with which
all Java programmers should be familiar. Therefore, this chapter provides an
introduction to this important GUI framework.
It is important to state at the outset that Swing is a very large topic that requires an
entire book of its own. This chapter can only scratch its surface. However, the material
presented here will give you a general understanding of Swing, including its history,
basic concepts, and design philosophy. It then introduces five commonly used Swing
components: the label, push button, text field, check box, and list. Although this
chapter describes only a small part of Swing’s features, after completing it, you will be
able to begin writing simple GUIbased programs. You will also have a foundation upon
which to continue your study of Swing.
Dostları ilə paylaş: