All pastes #208901 Raw Edit

malmat

public text v1 · immutable
#208901 ·published 2006-10-18 21:52 UTC
rendered paste body
import javax.swing.*;
import java.awt.*;

public class Kort extends JButton {
	
	private Icon bild;
	enum Status {DOLT, SYNLIGT, SAKNAS};
	Status s;
	
	public Kort(Icon i) {
		bild = i;
		s = Status.SAKNAS; 
		farg();
	}
	
	public Kort(Icon i, Status a) {
		bild = i;
		s = a;
		farg();
	}	
	
	public Status getStatus() {
		return s;
	}	
	
	public void setStatus(Status a) {
			s = a;
			farg();
	}
	
	public Kort copy() {
		return new Kort(this.bild, this.s);
	}
	
	public boolean equals(Kort k) {
		if(k.bild == this.bild) {
		return true;
		}
		else {
		return false;	
		}
	}
	public void farg() {
		if(s == Status.DOLT) {
			setIcon(null);
			setBackground(Color.BLUE);
		}
		else if(s == Status.SYNLIGT) {
			setIcon(bild);
		}
		else if(s == Status.SAKNAS) {
			setIcon(null);
			setBackground(Color.WHITE);
		}
	}
}