package leaf.ui;

import java.awt.Insets;

import com.evolute.utils.images.ImageException;
import com.evolute.utils.images.ImageIconLoader;

public class LeafIconButton extends LeafButton
{
	private static final long serialVersionUID = 1L;

	private LeafIconButton( String imagePath ) throws ImageException
	{
		super(ImageIconLoader.loadImageIcon( imagePath ));
	}
	
	public static LeafIconButton createButton( String imagePath )
	{
		LeafIconButton result = null;
		if( imagePath != null )
		{
			try
			{
				result = new LeafIconButton(imagePath);
				result.setMargin( new Insets(0,0,0,0) );
			} catch( ImageException e )
			{
				e.printStackTrace();
			}
		}
		return result;
	}
	
	public static LeafIconButton createButton( String title, String imagePath )
	{
		LeafIconButton result = createButton( imagePath );
		if( result != null )
		{
			result.setText( title );
		}
		return result;
	}
	
}
