/*
 * Copyright (c) 2002-2007 TeamDev Ltd. All rights reserved.
 *
 * Use is subject to license terms.
 *
 * The complete licence text can be found at
 * http://www.teamdev.com/winpack/license.jsf
 */
package com.jniwrapper.win32.ie.samples.demo.components;

import com.jniwrapper.win32.gdi.Icon;

import java.awt.Dimension;
import java.io.IOException;
import java.net.URL;
import java.net.MalformedURLException;

/**
 * @author Serge Piletsky
 */
public class FavoriteIcon extends Icon
{
    private static final String FAVORITE_ICON_FILE = "/favicon.ico";

    public FavoriteIcon(String url) throws IOException, MalformedURLException
    {
        URL inURL = new URL(url);
        URL favoriteIconURL = new URL(inURL.getProtocol(), inURL.getHost(), FAVORITE_ICON_FILE);
        load(favoriteIconURL.openStream(), new Dimension(16, 16));
    }
}
