}
@Override
public void paintComponent(Graphics g) {
if (toolbar.getPressed() == this) {
Dimension dim = item.getDimension(toolbar.getOrientation());
Color defaultColor = g.getColor();
GraphicsUtil.switchToWidth(g, 2);
g.setColor(Color.GRAY);
g.fillRect(BORDER, BORDER, dim.width, dim.height);
GraphicsUtil.switchToWidth(g, 1);
g.setColor(defaultColor);
}
Graphics g2 = g.create();
g2.translate(BORDER, BORDER);
item.paintIcon(ToolbarButton.this, g2);
g2.dispose();
// draw selection indicator
if (toolbar.getToolbarModel().isSelected(item)) {
Dimension dim = item.getDimension(toolbar.getOrientation());
GraphicsUtil.switchToWidth(g, 2);
g.setColor(Color.BLACK);
g.drawRect(BORDER, BORDER, dim.width, dim.height);
GraphicsUtil.switchToWidth(g, 1);
}