package com.uvigo.mhp.ui;

import java.awt.*;
import java.io.*;
import java.net.*;
import org.havi.ui.*;

public class HMenuElement extends Component implements Serializable
{
    private Image selectedImage, notSelectedImage;
    private String label;
    private MediaTracker trk;
    
    public HMenuElement(String s)
    {
        this(s,"","");
    }
    
    public HMenuElement(String s, String image)
    {
        this(s,image,image);
    }
    
    public HMenuElement(String s, String notSelectedURL, String selectedURL)
    {
        trk=new MediaTracker(this);
        
        if ((selectedURL!=null) && (!(selectedURL.equals(""))))
            try
            {
                URL url=new URL(selectedURL);
                selectedImage=Toolkit.getDefaultToolkit().getImage(url);
                trk.addImage(selectedImage,0);
                trk.waitForAll();
            }
            catch (Exception ex)
            {
                ex.printStackTrace();
            }
        
        if ((notSelectedURL!=null) && (!(notSelectedURL.equals(""))))
            try
            {
                URL url=new URL(notSelectedURL);
                notSelectedImage=Toolkit.getDefaultToolkit().getImage(url);
                trk.addImage(notSelectedImage,0);
                trk.waitForAll();
            }
            catch (Exception ex)
            {
                ex.printStackTrace();
            }
        
        label=s;
    }
    
    public String getLabel()
    {
        return label;
    }
    
    public Image getSelectedImage()
    {
        return selectedImage;
    }
    
    public Image getNotSelectedImage()
    {
        return notSelectedImage;
    }
    
    public void setLabel(String s)
    {
        label=s;
    }
    
    public void setSelectedImage(Image image)
    {
        selectedImage=image;
    }
    
    public void setNotSelectedImage(Image image)
    {
        notSelectedImage=image;
    }
    
    public String toString()
    {
        return(getLabel());
    }
}