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

📄 squareicon.java

📁 Java样例程序集合:2D
💻 JAVA
字号:
import javax.swing.Icon;import java.awt.Color;import java.awt.Component;import java.awt.Graphics;/*  * XMarksTheSpot is used by the ButtonDemo version used by the   * answer to exercise 2 of the Performing Custom Painting lesson: * http://java.sun.com/docs/books/tutorial/uiswing/QandE/questions-ch6.html */public class SquareIcon implements Icon {    private static final int SIZE = 10;            public void paintIcon(Component c, Graphics g,                          int x, int y) {        if (c.isEnabled()) {            g.setColor(Color.RED);        } else {            g.setColor(Color.GRAY);        }                g.fillRect(x, y, SIZE, SIZE);    }        public int getIconWidth() {        return SIZE;    }        public int getIconHeight() {        return SIZE;    }}

⌨️ 快捷键说明

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