import javax.swing.*;
import java.awt.Graphics;
import java.awt.*;
import java.awt.event.*;

public class  buttonA0 extends JApplet implements ActionListener
{ 
  JPanel inputPanel;
  JButton b;
  
  public void init()
  {
  inputPanel=new JPanel();      
  b=new JButton("Push button to change screen color");
  b.addActionListener(this);
  inputPanel.add(b);
  add(inputPanel); 
  }
  public void actionPerformed( ActionEvent e)
  {
  int red    =(int)(255.0*Math.random());
  int green  =(int)(255.0*Math.random());
  int blue   =(int)(255.0*Math.random());
  Color c=new Color(red,green, blue);
  inputPanel.setBackground(c);
  repaint();
  }

    public static void main(String s[])
    {
        JFrame f = new JFrame("Applet Graphic");
        f.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
        JApplet applet = new buttonA0();
        f.getContentPane().add("Center", applet);
        applet.init();
        f.setSize(800,500);
        f.setVisible(true); 
    }  
}
