/* This example demonstrates how use Checkboxes. */ import java.awt.*; import java.applet.*; public class CheckboxTest extends Applet { Checkbox bold = new Checkbox("Bold"); Checkbox italic = new Checkbox("Italic"); int fontStyle; public void init() { bold.setBackground(Color.yellow); italic.setBackground(Color.yellow); add(bold); add(italic); setBackground(Color.yellow); } public boolean action(Event evt, Object arg) { if (evt.target instanceof Checkbox) { fontStyle = bold.getState() ? Font.BOLD : 0; fontStyle = fontStyle + (italic.getState() ? Font.ITALIC : 0); repaint(); return true; } return false; } public void paint(Graphics g) { Font f = new Font("TimesRoman", fontStyle, 24); g.setFont(f); g.drawString("I like Check Boxes!!!", 15, 85); } }