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

📄 imagecharicon.java

📁 一个JAVA写的连连看游戏,非常不错,是学习JAVA的好资料,值得下载
💻 JAVA
字号:
/*
 * Created on 2005-3-18 
 */
package jcase.lianliankan;

import java.awt.*;

public class ImageCharIcon extends SimpleCharIcon {

	/* 根据不同的字符绘制不同的图标
	 * @see javax.swing.Icon#paintIcon(java.awt.Component, java.awt.Graphics, int, int)
	 */
	public void paintIcon(Component c, Graphics g, int x, int y) {
		Font dfont = g.getFont();
				Color dcolor =g.getColor();		
				g.setFont(charFont);
				
				if(isSelected()){
					g.setColor(Color.RED);
					g.drawRect(x,y,getIconWidth(),getIconHeight());
				}			
				Image icon = Configuration.getImage(getChar());
				int w=icon.getWidth(c);
				int h=icon.getHeight(c);
				double xscale=getIconWidth()*1.0/w;
				double yscale=getIconHeight()*1.0/h;
				double scale;
				scale=Math.min(xscale,yscale);
				w*=scale;
				x+=(getIconWidth()-w)/2;
				h*=scale;
				y+=(getIconHeight()-h)/2;
				g.drawImage(icon,x,y,w,h,c);		
				g.setColor(dcolor);
				g.setFont(dfont);
	}

	/**
	 * 
	 */
	public ImageCharIcon() {
		super();		
	}

	/**
	 * @param c
	 */
	public ImageCharIcon(char c) {
		super(c);		
	}
	
}

⌨️ 快捷键说明

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