ImageIconWidget.java :  » J2ME » Persian-Mobile-Dictionary » pmd » gui » Java Open Source

Java Open Source » J2ME » Persian Mobile Dictionary 
Persian Mobile Dictionary » pmd » gui » ImageIconWidget.java
/* 
 * Copyright (c) 2007, persianmobidict.sourceforge.net
 * Released under the GNU General Public License
 */

package pmd.gui;

import javax.microedition.lcdui.*;

/**
 *
 * @author  Hooman Valibeigi
 */
public class ImageIconWidget extends Widget {
    
    private Image icon;
    
    
    public ImageIconWidget(Image icon) {
        setFocusable(false);
        setIcon(icon);
    }
    
    
    public Image getIcon() {
        return icon;
    }
    
    public void setIcon(Image icon) {
        if (icon == null)
            throw new IllegalArgumentException("null");
        this.icon = icon;
        repaint();
    }
    
    public void paintWidget(Graphics g) {
        g.drawImage(icon, ((getWidth() - icon.getWidth()) >> 1), ((getHeight() - icon.getHeight()) >> 1), 0);
    }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.