import java.awt.*;
import java.awt.event.*;
public class SetBGColor extends Frame{
	Label l;
	SetBGColor(){
		super("AWT set BGColor to Pink");
		l = new Label("This is a Label"); 
		l.setBounds(25, 150, 250, 50);	 // Label Dimensions x,y,width,height 
		l.setAlignment(Label.CENTER);	 // aligns label text in center
		this.add(l);
		this.setBackground(Color.PINK);  // sets the BGColor of the Frame Window to Pink
		this.setSize(300, 300); 	 // Dimensions of the Frame Windo	
		this.setLayout(null);
		this.setVisible(true);
		this.addWindowListener(new WindowAdapter() {         // Registers WindowListener using Adapter class
			public void windowClosing(WindowEvent e) {   // WindowEvent receives and processes the event	
				dispose(); 	// please see the comment written in the end	  
			}  
		});
	}
	public static void main(String[] args) {
		new SetBGColor();
	}
}

/* 

AWT Window or Frame can be closed by calling dispose() or System.exit() inside 					      		 windowClosing() method, found in WindowListener interface and WindowAdapter class

*/  

