/*
 * @(#)ButtonBuilder.java	1.0 11-Apr-07
 *
 * IIT Bombay, 
 * Licensed under a Creative Commons Attribution-Noncommercial-Share Alike 2.5 License.
 */
package classes.main.components;

import interfaces.IAppletGUIBuilder;

import java.applet.Applet;
import java.awt.Button;
import java.awt.Component;
import java.awt.event.ActionListener;

import types.Bounds;

/**
 * Builder class for Button component
 *
 * @author  Prathab, Mukesh
 * @version 1.0, 11-Apr-07
 */
public class ButtonBuilder implements IAppletGUIBuilder {

	/** 
	 * Builds the respective component (control) and adds to Applet.
	 * @param bounds the coordinate bounds where the component to be placed
	 * @param component the component that need to be added
	 * @param applet the applet frame to which the component to be added
	 * @param object object required to intialize the component
	 * @see interfaces.IAppletGUIBuilder#build(types.Bounds, java.awt.Component, java.applet.Applet,java.lang.Object)
	 */
	public void build(Bounds bounds,Component component, Applet applet, Object object) {
		Button button = (Button) component;
		button.setBounds(bounds.x1,bounds.y1,bounds.x2,bounds.y2);
		applet.add(button);
		ActionListener actionListener = (ActionListener) applet;
		button.addActionListener(actionListener);
	}
}
