12.10.1 JCheckBox

The application of Figs. 12.1712.18 uses two JCheckBoxes to select the desired font style of the text displayed in a JTextField. When selected, one applies a bold style and the other an italic style. If both are selected, the style is bold and italic. When the application initially executes, neither JCheckBox is checked (i.e., they’re both false), so the font is plain. Class CheckBoxTest (Fig. 12.18) contains the main method that executes this application.

 1   // Fig. 12.17: CheckBoxFrame.java 2   // JCheckBoxes and item events. 3   import java.awt.FlowLayout; 4   import java.awt.Font; 5   import java.awt.event.ItemListener; 6   import java.awt.event.ItemEvent; 7   import javax.swing.JFrame; ...

Get Java™ How To Program (Early Objects), Tenth 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.