squareicon.java
来自「jsf、swing的官方指南」· Java 代码 · 共 33 行
JAVA
33 行
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 + =
减小字号Ctrl + -
显示快捷键?