Chapter 1
Fun with Fonts and Colors
In This Chapter
Setting the font of a text control
Finding out what fonts are available
Playing with colors
Working with system colors
Setting foreground and background colors
In this chapter, I look at ways of dressing up the text that appears in Swing controls. In particular, I show you how to change the font that text is displayed in — including bold, italic, and size — as well as how to change the color of your text.
Most of the examples work with labels, but the methods you call to set the font and color are available to all Swing components because they're defined by the Component class, which all Swing components inherit.
Also, the information about fonts and colors that I present in this chapter applies to graphics created with the methods of the Graphics2D class, which I discuss in Book IX, Chapter 2.
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
For a full discussion of Swing, see ...