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.
Get Java All-in-One For Dummies, 4th 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.