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

📄 mappanel.java

📁 一个贪吃蛇游戏
💻 JAVA
字号:
/**
 * @(#)MapPanel.java
 * @A panel used to draw map.
 *
 * @Link Scholes
 * @version 1.00 2008/7/21
 */

package GUI;

//Java core packages
import java.awt.*;

//Java extension packages
import javax.swing.*;

public class MapPanel extends JPanel
{
	private int type;
	private ImageIcon icon;
	
	//construct a map panel with specified type
	public MapPanel(int n)
	{
		type = n;
		setPreferredSize(new Dimension(32,32));
		setVisible(true);
	}
	
	//get the type of the map panel
	public int getType()
	{
		return type;
	}
	
	//set the map panel with the specified type
	public void setType(int n)
	{
		type = n;
		repaint();
	}
	
	//draw the picture representing the type of the map panel
	protected void paintComponent(Graphics g)
	{
		super.paintComponent(g);
		icon = new ImageIcon("img\\" + type + ".jpg");
		g.drawImage(icon.getImage(),0,0,null);
	}
}	//end class MapPanel

⌨️ 快捷键说明

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