//----------------------------BEGIN LICENSE----------------------------
/* 
 * Willow : the Open Source WorkFlow Project
 * Distributable under GNU LGPL license by gun.org
 *
 * Copyright (C) 2004-2010 huihoo.org 
 * Copyright (C) 2004-2010  ZosaTapo <dertyang@hotmail.com> 
 * 
 * ====================================================================
 * Project Homepage : http://www.huihoo.org/god4j
 * Source Forge     : http://sourceforge.net/projects/huihoo
 * Mailing list     : god4j@lists.sourceforge.net 
 */
//----------------------------END  LICENSE-----------------------------
package org.huihoo.god4j.editor.panels;
import java.awt.Dimension;
import java.awt.Insets;

import javax.swing.AbstractButton;
import javax.swing.ImageIcon;
import javax.swing.JButton;

import org.huihoo.god4j.util.ImageLoader;
import org.huihoo.god4j.util.StringManager;

public class JavaButton extends JButton
{
	protected static StringManager sm = StringManager.getManager("org.huihoo.god4j.editor");
	/**
	* Creates 'push' button with specified attributes.
	*
	* @param name      the name to be written on the button.
	* @param keyToIcon when an <i>imageSuffix</i> is added to
	*                  this keyword, it presents the resource
	*                  path keyword within property file. This
	*                  resource represents an image file.
	* @param d         dimension of button.
	*/
	public JavaButton(String name, String keyToIcon, Dimension d)
	{
		super(name);
		this.setText(name);

		ImageIcon icon = ImageLoader.getImageIcon(ImageLoader.getImageName(keyToIcon + "Image"));
		if (icon != null)
		{
			setIcon(icon);
		}

		setVerticalTextPosition(AbstractButton.CENTER);

		Insets i = getInsets();
		Dimension di = new Dimension(d);
		di.width = di.width + i.left + i.right;
		di.height = di.height + i.top + i.bottom;
		setMinimumSize(new Dimension(di));
		setMaximumSize(new Dimension(di));
		setPreferredSize(new Dimension(di));
	}
	
	public void applyChanges()
	{
	}
}