import javax.swing.*;
import java.awt.Font;

public class CheckAddRemove{
  public static void main(String args[]){
     JFrame frame=new JFrame("CheckAddRemove");
     frame.setSize(600,600);
     frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     JButton button1=new JButton("Start");
     button1.setFont(new Font("Arial",Font.BOLD,40));
     JEventQueue events=new JEventQueue();
     events.listenTo(button1,"Button1");
     JBox body = JBox.vbox(button1);
     frame.add(JBox.vbox(JBox.vglue(),
        JBox.hbox(JBox.hglue(),body,JBox.hglue()),
        JBox.vglue()));
     frame.setVisible(true);

     events.waitEvent();//wait for button press
     body.removeAll();
     JRadioButton button2=new JRadioButton("Button2");
     events.listenTo(button2,"Button2");
     body.add(button2);
     frame.validate();
     frame.repaint();
       
     events.waitEvent();//wait for button press
     body.removeAll();
     JCheckBox button3=new JCheckBox("Button3");
     events.listenTo(button3,"Button3");
     body.add(button3);
     frame.validate();
     frame.repaint();
     
     events.waitEvent();//wait for button press
     System.exit(0);
  }
}
