/* This example demonstrates how use Radiobuttons. */ import java.awt.*; import java.applet.*; public class RadiobuttonTest extends Applet { CheckboxGroup cbg = new CheckboxGroup(); Checkbox small = new Checkbox("Small", cbg, true); Checkbox medium = new Checkbox("Medium", cbg, false); Checkbox large = new Checkbox("Large", cbg, false); Checkbox extraLarge = new Checkbox("Extra Large", cbg, false); int fontSize = 10; public void init() { small.setBackground(Color.yellow); medium.setBackground(Color.yellow); large.setBackground(Color.yellow); add(small); add(medium); add(large); add(extraLarge); extraLarge.setBackground(Color.yellow); setBackground(Color.yellow); } public boolean action(Event evt, Object arg) { if (evt.target instanceof Checkbox) { if (evt.target == small) fontSize = 10; else if (evt.target == medium) fontSize = 16; else if (evt.target == large) fontSize = 24; else fontSize = 30; repaint(); return true; } return false; } public void paint(Graphics g) { Font f = new Font("TimesRoman", Font.BOLD, fontSize); g.setFont(f); g.drawString("I love Radiobuttons!!!!", 5, 95); } }