myicon.java
来自「java绘图 java awt 经典绘图的例子,对于初学awt模块的人非常有帮助」· Java 代码 · 共 46 行
JAVA
46 行
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package awt;import java.awt.Color;import java.awt.Component;import java.awt.Graphics;import javax.swing.Icon;/** * * @author zhaolin */public class MyIcon implements Icon{ private int width,height; public MyIcon(int w,int h){ this.width = w; this.height = h; } public void paintIcon(Component c, Graphics g, int x, int y) { g.setColor(Color.BLACK); g.fillRect(x, y, width, height); int span = width/3; Color color = Color.WHITE; for (int i = 0; i < 3; i++) { g.setColor(color); g.fillOval(i*span+3+x,2+y, span-4, height-4); color = color.darker(); } } public int getIconWidth() { return this.width; } public int getIconHeight() { return this.height; } }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?