Home>
import java.awt. *;
import javax.swing. *;
import java.awt.event. *;
public class test extends japplet
implements actionlistener {
  jtextfield jtf;
  public void init () {
    container contentpane=getcontentpane ();
    contentpane.setlayout (new flowlayout ());
    jradiobutton b1=new jradiobutton ("a");
    b1.addactionlistener (this);
    contentpane.add (b1);
    jradiobutton b2=new jradiobutton ("b");
    b2.addactionlistener (this);
    contentpane.add (b2);
    jradiobutton b3=new jradiobutton ("c");
    b3.addactionlistener (this);
    contentpane.add (b3);
    buttongroup bg=new buttongroup ();
    bg.add (b1);
    bg.add (b2);
    bg.add (b3);
    jtf=new jtextfield (15);
    contentpane.add (jtf);
  }
  public void actionperformed (actionevent ae) {
    jtf.settext (ae.getactioncommand ());
  }
}
  • Previous Example analysis of tree and scroll bar usage in swing
  • Next Android implementation of Service to obtain the current location (GPS + base station)