Java Reference
In-Depth Information
};
EventQueue.invokeLater(runner);
}
}
Tip To make sure that cancel-type buttons get the input focus no matter what when using InputVerifier ,
use the setVerifyInputWhenFocusTarget(false) method with the component.
Summary
In this chapter, you looked at the many ways of dealing with event handling when using Swing
components. Because Swing components are built on top of AWT components, you can use the
delegation-based event-handling mechanism common with those components. You then learned
about the multithreading limitations of the Swing components and how to get around them
with the invokeAndWait() and invokeLater() methods of EventQueue . You also explored how
the Swing components use the JavaBeans PropertyChangeListener approach for notification of
bound property changes.
Besides exploring the similarities between the Swing components and AWT components,
you also looked at several of the new features that the Swing library offers. You explored the
Action interface and how it can simplify complex user-interface development by completely
separating the event-handling task from the visual component. You looked at the technique for
registering KeyStroke objects to components to simplify listening for key events. Finally, you
explored Swing's focus management capabilities and how to customize the focus cycle and use
the FocusTraversalPolicy and KeyboardFocusManager , as well as validating input with the
InputVerifier .
In Chapter 3, you'll meet the Model-View-Controller (MVC) architecture of the Swing
component set. You'll learn how MVC can make your user interface development efforts
much easier.
 
Search WWH ::




Custom Search