import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class ApplicationFrame extends JFrame {

	public ApplicationFrame()	{
		this("ApplicationFrame v1.0");
	}
	
	public ApplicationFrame(String title) {
		super(title);		
		createUI();
	}
  
	protected void createUI() {
		setSize(500, 400);
    	center();
		contentPane = getContentPane();
		contentPane.setLayout(new BorderLayout());
		
    	addWindowListener(new WindowAdapter() {
    		public void windowClosing(WindowEvent e) {
        		dispose();
        		System.exit(0);
      		}
    	});
	}
	
/*	public void add(Component c, Object constraints)	{
		contentPane.add(c, constraints);
	}
*/

	public Component  add(Component c)	{
		System.out.println("Ajout d'un Component");
		contentPane.add(c,BorderLayout.CENTER);
		return c;
	}

	public Component  add(Component c, String position)	{
		System.out.println("Ajout d'un Component");
		contentPane.add(c,position);
		return c;
	}

	public void  add(JPanel c)	{
		System.out.println("Ajout d'un JPanel");
		contentPane.add(c,BorderLayout.CENTER);
	}

  
	public void center() {
    	Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    	Dimension frameSize = getSize();
    	int x = (screenSize.width - frameSize.width) / 2;
    	int y = (screenSize.height - frameSize.height) / 2;
    	setLocation(x, y);
	}

private Container contentPane;
  
}