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
SwingUtilitiesclass andSwingConstantsinterface- Timers
The
Timerclass- Tooltips
The
ToolTipManagerandJToolTipclasses- Rendering
The
CellRendererPane,Renderer, andGrayFilterclasses- Events
The
EventListenerList,KeyStroke,MouseInputAdapter, andSwingPropertyChangeSupportclasses
Figure 27-1 shows the classes covered in this chapter.

Figure 27-1. Class diagram for the utility classes
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access