Snippets

Ettar Java ImageIcon Equals

Created by Ettar
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.security.MessageDigest;
import java.util.Arrays;

import javax.imageio.ImageIO;
import javax.swing.ImageIcon;

public class imgic extends ImageIcon {
	
	BufferedImage testImg;
	
	public imgic(BufferedImage test){
		if(test!=null){
			this.testImg=test;
			this.setImage(test);
		}
	}
	
	public BufferedImage gettestImg(){
		return testImg;
	}
	
	@Override
	public boolean equals(Object other){
		
		if(other!=null){
			if(other instanceof imgic){
				imgic otherObj = (imgic) other;
				if(otherObj.gettestImg()==null&&this.testImg==null){
					return true;
				}else if(this.hashCode()==other.hashCode()){
					return true;
				}	
			}
		}
		return false;
	}
	
	@Override
	public int hashCode(){
		//do something
	}
}

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.