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

📄 mybutton.java

📁 扫雷的源代码,包结构采用经典的MVC模式,包括模型、控制、视图三部分
💻 JAVA
字号:
/*
 * Created on Mar 25, 2005
 *
 * TODO add a coordinate to a JLabel as a button, to mark the location of this button
 */
package view;

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

import model.Location;

import javax.swing.JLabel;

/**
 * @author mqqqvpppm
 * 
 * TODO add a coordinate to a JLabel as a button, to mark the location of this
 * button
 */
public class MyButton extends JLabel {
	private Location location;

	public Location getMyLocation() {
		return location;
	}

	MyButton(Location aLocation) {
		super();
		this.location = aLocation;
	}

	public void paintComponent(Graphics g) {
		super.paintComponent(g);
		if (image != null) {
			Graphics2D g2 = (Graphics2D) g;
			g2.drawImage(image, 0, 0, getWidth(), getHeight(), null);
		}
	}
	
	public void draw(Image image){
		this.image = image;
		repaint();
	}

	MyButton(int x, int y) {
		super();
		location = new Location(x, y);
	}
	private Image image;
}

⌨️ 快捷键说明

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