Java Swing O Reilly If a container has (Web hosting contract)

Java Swing O Reilly If a container has a focus cycle of its own, it should override the JComponent method isFocusCycleRoot() and return true. If the method returns true, then the container is known as the root container of the focus cycle. The root container is allowed to indicate whether or not it is managing focus . If it is, it should override the isManagingFocus() method and return true. When a container is managing focus, the focus manager is disabled and all key events are sent to the container for processing. By default, the isManagingFocus() method returns false, allowing the Swing focus manager to handle the task of shifting and traversing the focus. With any JComponent, you can explicitly name the component that should receive the focus next by setting the nextFocusableComponent property. In addition, focus can be programmatically requested through the JComponent method requestFocus() , which the focus manager can call to shift the focus to this component. This is often done when the user selects the object (i.e., presses a JButton). If you don’t want your component to be able to respond to requestFocus() calls, you can set the requestFocusEnabled property of JComponent to false. There is an important distinction here: setting the requestFocusEnabled property to false does not mean that the focus cannot be traversed onto your component; it simply means that it cannot be programmatically requested. JComponent provides a similar property, focusTraversable, that you can enable or disable to specify whether a component receives the focus when traversed. Note the difference between the two. If you wanted to allow a JButton to gain the focus when clicked, but skipped in the focus cycle, you would set the requestFocusEnabled property to true and the focusTraversable property to false. If you wanted to prevent focus from being shifted to the JButton when clicked, you would set the requestFocusEnabled property to false. If you wanted the JButton to ignore focus traversal and focus requests (i.e., never have the focus), you would set both properties to false. We discuss the concept of focus and the FocusManager in detail in Chapter 28. 3.3.2.12 Keyboard Events Swing components can be programmed to trigger various actions when certain keystrokes occur. For example, Swing components automatically handle focus-related keyboard events. The default focus manager searches only for TAB and SHIFT-TAB keystrokes, altering the focus and consuming the keystrokes when detected. If the focus manager does not know how to handle a keystroke, it checks to see whether the processComponentKeyEvent() method can consume it. This method currently does nothing. However, you can override it in a subclass if you want to react to a keystroke in your own way. If neither of these succeeds in consuming the key event, the JComponent class checks to see if a keyboard action has been registered for that keystroke. A keyboard action binds a Swing action and a keystroke to a specific component. - 66 -
We recommend high quality webhost to host and run your jsp application: christian web host services.