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

public class  buttonP01 extends JPanel implements ActionListener
{ 
  JButton b;
  JPanel inputPanel;
  Color c;
  public buttonP01()
  {    	
       c=Color.blue;
	   setLayout(new BorderLayout());     
       inputPanel=new JPanel();
       inputPanel.setBackground(c);
       b=new JButton("Push button to change background color");
       b.addActionListener(this);
       add(b,BorderLayout.NORTH);
       add(inputPanel,BorderLayout.CENTER); 
  }
  
  public void actionPerformed( ActionEvent e)
  {
  c=JColorChooser.showDialog(null,"color of the background ",c );
  inputPanel.setBackground(c);
  repaint();
  }

}
