for something completely different. In Chapter 3 we offered a terse
discussion of various properties of
that can be used to control how a component handles focus. Here, we
look at each of those properties more in-depth, and discuss some of
the peculiarities of using focus in Swing.
You’re probably aware that you can shift the focus around in Swing using the TAB key and the SHIFT-TAB key. The path that the focus follows from one component to the next is called the focus cycle. The focus cycle is determined by the focus manager. By default, the focus cycle is dictated by the position of the components in the container: those components with a smaller x,y position always get the focus first. Consequently, with the help of the Swing focus manager, the default focus will cycle from left to right and top to bottom — much like reading a book. The TAB key moves the focus one step ahead in its current focus cycle. SHIFT-TAB moves it one step back.
Five properties in
deal with focus. It is important to
note that they are used only in conjunction with the Swing focus
DefaultFocusManager. The properties
are summarized in Table 28.5. Let’s go over
each of these properties and discuss how they impact the focus in
Table 28-5. Focus-Related Properties in JComponent
If true, indicates that the component contains a group of child components all contained within their own focus cycle