《Java2图形设计卷II:Swing》配套光盘源码

源代码在线查看: coloricon.java

软件大小: 4504 K
上传用户: guigong
关键词: Java2 Swing 图形 光盘
下载地址: 免注册下载 普通下载 VIP

相关代码

				import java.awt.*;
				import javax.swing.*;
				
				class ColorIcon implements Icon {
					private Color fillColor;
					private int w, h;
				
					public ColorIcon(Color fillColor, int w, int h) {
						this.fillColor = fillColor;
						this.w = w;
						this.h = h;
					}
					public void paintIcon(Component c, Graphics g, int x, int y) {
						g.setColor(Color.black);
						g.drawRect(x, y, w-1, h-1);
						g.setColor(fillColor);
						g.fillRect(x+1, y+1, w-2, h-2);
					}
					public int getIconWidth() {
						return w;
					}
					public int getIconHeight() {
						return h;
					}
				}
							

相关资源