Chapter 27. Swing Utilities
There are many tasks you run into that are common and not
terribly difficult. Hence, they get rewritten several times in several
small variations. Ideally, you would code the task up into a method or
class, and keep it around for reuse later. There are several small classes
and methods strewn about the javax.swing
package that fall into this
category. This chapter presents those bits and pieces and points out where
you might be able to put them to use in your own code. They may not be as
fundamental as the wheel, but anytime you don’t have to rewrite something,
you’re doing your part to create better OO programs!
We’ve called this chapter “Swing Utilities,” but in fact it covers a range of subjects. In order of presentation, we’ll look at:
- Swing utilities
The
SwingUtilities
class andSwingConstants
interface- Timers
The
Timer
class- Tooltips
The
ToolTipManager
andJToolTip
classes- Rendering
The
CellRendererPane
,Renderer
, andGrayFilter
classes- Events
The
EventListenerList
,KeyStroke
,MouseInputAdapter
, andSwingPropertyChangeSupport
classes
Figure 27-1 shows the classes covered in this chapter.
Figure 27-1. Class diagram for the utility classes
Get Java Swing, 2nd 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.