📄 iconx.java
字号:
package edu.ou.kmi.buddyspace.utils;
import java.awt.*;
import javax.swing.*;
/**
* An Icon that paint another icon plus extra things (e.g. emphasis)
* @author Chris Denham
* @version 1.0
*/
public class IconX implements Icon {
private boolean emphasis = true;
private int width;
private int height;
public boolean getEmphasis() { return emphasis; }
public void setEmphasis(boolean emphasis) { this.emphasis = emphasis; }
private Icon icon = null;
public IconX(Icon icon) {
this.icon = icon;
width = icon.getIconWidth() + 6;
height = icon.getIconHeight() + 6;
// This ensures size rounded to next lowest odd number
// to prevent problems with concentric drawOval operations.
width += width % 2 - 1;
height += height % 2 - 1;
}
public Icon getIcon() { return icon; }
public void setIcon(Icon icon) { this.icon = icon; }
public int getIconWidth() { return width; }
public int getIconHeight() { return height; }
public void paintIcon(Component c, Graphics g, int x, int y) {
icon.paintIcon(c, g, x + 3, y + 3);
if (emphasis) {
Color oldColor = g.getColor();
int w = width - 1, h = height - 1;
g.setColor(java.awt.Color.blue);
g.drawOval(x + 0, y + 0, w - 0, h - 0);
g.drawOval(x + 1, y + 1, w - 2, h - 2);
//g.drawOval(x + 2, y + 2, w - 4, h - 4);
g.setColor(oldColor);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -