Java AWT Radio Buttons Applet GUI

Java AWT Radio Buttons Applet GUI

Application to Applet Migration

Following steps can be noticed in the above program to develop an applet instead of application.

  1. Import java.applet package
  2. Extend Applet instead of Frame
  3. Write init() method in place of constructor
  4. No main() method
  5. Write an extra HTML file to run the applet
  6. No set methods like setSize() as they are given in HTML file
  7. No window closing code as window closing is implicit

Remember the default layout manager for Applet is FlowLayout which can be changed (like BorderLayout for Frame). In the above program, the default FlowLayout is used.

Note: In applet, window closing code is not required. It is automatic.

Note: User's selection, messages or component information etc. can be displayed in five ways. In this program, it is displayed as a Label component.

2 thoughts on “Java AWT Radio Buttons Applet GUI

  1. v.s.

    sir y the same code in frame not working its not displaying neither checkboxes nor any radio button just showing the label “I Display Your Selection” at the middle of the frame

    import java.awt.*;
    import java.awt.event.*;
    public class Courses extends Frame implements ItemListener
    Checkbox mbaBox, btechBox, archBox;
    CheckboxGroup cbg;
    Label lab;
    public Courses()
    cbg = new CheckboxGroup();
    mbaBox = new Checkbox(“MBA”, cbg, true);
    btechBox = new Checkbox(“B.Tech”, cbg, true);
    archBox = new Checkbox(“B.Arch”, cbg, true);
    lab = new Label(“I Display Your Selection”);



    setTitle(“radio Boxes in Action”);
    setSize(300, 300);

    public void itemStateChanged(ItemEvent e)
    String str = “”;
    if(mbaBox.getState() == true)
    str = “You study MBA.”;
    else if(btechBox.getState() == true)
    str = “You study B.Tech.”;
    else if(archBox.getState() == true)
    str = “You study B.Arch.”;


    public static void main(String…aa)
    new Courses();


Leave a Reply

Your email address will not be published. Required fields are marked *