Chapter 4

Choosing from a List

In This Chapter

arrow Combo boxes

arrow Lists

arrow Spinners

arrow Trees

A whole category of Swing components is designed to let the user choose one or more items from a list. This chapter presents four such controls. The first three — JList, JComboBox, and JSpinner — are straightforward. The fourth — JTree — is a bit more complicated but worth the effort.

warning.eps If you put a JTree control in a frame, your friends will surely think you're some kind of guru. They'll start pestering you with questions and asking for your help. As a result, use this component only if your application really needs it — and if you feel up to the technical challenge of figuring out how it works.

Using Combo Boxes

warning.eps A combo box is a combination of a text field and a drop-down list from which the user can choose a value. If the text-field portion of the control is editable, the user can enter a value in the ...

Get Java All-in-One For Dummies, 4th 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.