|
|
|
|
|
|
SolutionDownload RadioButtonsTest source code.HTML Interface to Applet<APPLET CODEBASE="/applets/magelang/AWT-Training/classes/" CODE="RadioButtonsTest.class" WIDTH=380 HEIGHT=30 ALIGN=CENTER></APPLET> Java Codeimport java.awt.*; public class RadioButtonsTest extends java.applet.Applet { public void init() { RadioButtons test = new RadioButtons(); add(test); } } /** * Component containing a group of Checkboxes */ class RadioButtons extends FormElement { protected CheckboxGroup cbg; protected String label = "Java for: "; public RadioButtons() { setLayout(new FlowLayout()); add(new Label(label)); cbg = new CheckboxGroup(); add(new Checkbox("C++ Programmers", cbg, true)); add(new Checkbox("Procedural Programmers", cbg, false)); } /** * Return a text representation of this field. * This method is required by the FormElement interface. * @return String the selected text */ public String getContents() { return label + " " + cbg.getCurrent().getLabel(); } } |