/*This program will illustrate how to include radio buttons
into a java applet*/
import java.applet.*;//imports Applet package
import java.awt.*;//imports the abstrac window Tool Kit (AWT) class.

public class radio extends Applet
	Checkbox angle;
	Checkbox radians, degrees;
	CheckboxGroup cbg;
	Label Prompt1 = new Label ("Enter an angle measure to convert ");
	String msg ="";
	TextArea Result=new TextArea(10,35);
	TextField StrNum=new TextField(5);
	Button convert=new Button ("Convert");
	public void init()
	{	cbg = new CheckboxGroup(); // Intializing the group of check boxes.
		// The check box group will contain these check boxes called cbg.
		// (name, group. on or off)
		radians = new Checkbox("Convert from degrees to radians",cbg,true);
		degrees = new Checkbox("Convert from radians to degrees", cbg, false);
		add(radians);// adding the checkbox object for radians
		add(degrees);// adding the checkbox object for degrees
	public boolean action(Event clickedButton, Object thisObject)
		// this if will activate after the Convert button is selected
		if ( == convert)
		  msg = cbg.getCurrent().getLabel();// the check box name is places into a string
		  float ang=Float.valueOf(StrNum.getText()).floatValue();// enter angle
		  if (msg == "Convert from degrees to radians" | msg == "Convert from radians to degrees")
		    if (msg == "Convert from degrees to radians")	
			double ang_radians = (ang * Math.PI / 180);//converting to radians
			Result.appendText(+ang+" degrees = "+ang_radians+" radians");
			double ang_degrees = (ang * 180 / Math.PI);//converting to degrees
			Result.appendText(+ang+" radians = "+ang_degrees+" degrees");
		return true;

Output for