abstract class ChooserIcon implements Icon {
static final Icon DIR_ICON = new DirIcon();
static final Icon FILE_ICON = new FileIcon();
static final Icon UP_FOLDER_ICON = new UpFldIcon();
public int getIconWidth() { return 16; }
public int getIconHeight() { return 16; }
private static class DirIcon extends ChooserIcon {
public void paintIcon(Component c, Graphics g,
int x, int y) {
g.translate(x, y);
// folder main, tab
g.setColor(new Color(247, 241, 136));
g.fillRect(2, 4, 12, 7);
g.drawLine(2, 1, 5, 1);
// folder outline
g.setColor(new Color(207, 198, 14));
g.drawLine(0, 2, 13, 2);
g.drawLine(0, 2, 0, 11);
g.drawLine(0, 11, 13, 11);
g.drawLine(0, 2, 2, 0);
g.drawLine(2, 0, 5, 0);
// more...
g.translate(-x, -y);
}
}
private static class FileIcon extends ChooserIcon {
public void paintIcon(Component c, Graphics g,
int x, int y) {
...
}
}
private static class UpFldIcon extends ChooserIcon {
public void paintIcon(Component c, Graphics g,
int x, int y) {
...
}
}
}
|