⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 basebutton.java

📁 扫雷 程序 是我学JAVA的时候编的 希望大家 不嫌弃 不过 喜欢的 尽管拿走
💻 JAVA
字号:

import java.awt.Graphics;
import java.awt.Image;


public class BaseButton {
	public ButtonType type = null;
	protected Image img = null;
	private Position pos;
	public int num = 0;
	public Boolean isMine = false;
	
	public BaseButton(){}
	public BaseButton(Position p){
		pos = p;
	}
	
	public void setImage(Buttons bs){
		switch(type){
			case UserMine:
				img = bs.getUserMine();
				break;
			case Mine:
				img = bs.getMine();
				break;
			case Explosion:
				img = bs.getExplosion();
				break;
			case Empty:
				img = bs.getEmpty();
				break;
			case UserEmpty:
				img = bs.getUserEmpty();
				break;
		}
	}
	
	public void draw(Graphics g){
		g.drawImage(img,pos.getDrawPosX(), pos.getDrawPosY(),null);
		if(type == ButtonType.UserEmpty){
			if(num != 0)
				g.drawString(Integer.toString(num), pos.getDrawPosX()+5, pos.getDrawPosY()+15);
		}
	}
	
	public Position getPosition(){
		return pos;
	}
	
	public Boolean equalPos(BaseButton bb){
		return (pos.equal(bb.getPosition()));
	}
}

enum ButtonType{
	UserMine,Mine,Empty,UserEmpty,Explosion
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -