public void paintIcon(Component c,
Graphics g,
int x,
int y) {
JButton parentButton = (JButton)c;
ButtonModel buttonModel = parentButton.getModel();
Color backgroundColor = MetalLookAndFeel.getPrimaryControl();
Color internalBackgroundColor =
MetalLookAndFeel.getPrimaryControl();
Color mainItemColor =
MetalLookAndFeel.getPrimaryControlDarkShadow();
Color darkHighlightColor = MetalLookAndFeel.getBlack();
// ul = Upper Left and lr = Lower Right
Color ulLightHighlightColor = MetalLookAndFeel.getWhite();
Color lrLightHighlightColor = MetalLookAndFeel.getWhite();
// if the internal frame is inactive
if (parentButton.getClientProperty("paintActive") != Boolean.TRUE)
{
backgroundColor = MetalLookAndFeel.getControl();
internalBackgroundColor = backgroundColor;
mainItemColor = MetalLookAndFeel.getControlDarkShadow();
// if inactive and pressed
if (buttonModel.isPressed() && buttonModel.isArmed()) {
internalBackgroundColor =
MetalLookAndFeel.getControlShadow();
ulLightHighlightColor = internalBackgroundColor;
mainItemColor = darkHighlightColor;
}
}
// if the button is pressed and the mouse is over it
else if (buttonModel.isPressed() && buttonModel.isArmed()) {
internalBackgroundColor =
MetalLookAndFeel.getPrimaryControlShadow();
ulLightHighlightColor = internalBackgroundColor;
mainItemColor = darkHighlightColor;
// darkHighlightColor is still "getBlack()"
}
g.translate(x, y);
// fill background
g.setColor(backgroundColor);
g.fillRect(0,0, iconSize,iconSize);
// BOX drawing
// fill inside the box
g.setColor(internalBackgroundColor);
g.fillRect(3,7, iconSize-10,iconSize-10);
// light highlight
g.setColor(ulLightHighlightColor);
g.drawRect(3,7, iconSize-10,iconSize-10); // up,left
g.setColor(lrLightHighlightColor);
g.drawRect(2,6, iconSize-7,iconSize-7); // low,right
// dark highlight
g.setColor(darkHighlightColor);
g.drawRect(1,5, iconSize-7,iconSize-7); // outer
g.drawRect(2,6, iconSize-9,iconSize-9); // inner
// main box
g.setColor(mainItemColor);
g.drawRect(2,6, iconSize-8,iconSize-8); // g.drawRect(2,6, 8,8);
// ARROW drawing
// dark highlight
g.setColor(darkHighlightColor);
// down,left to up,right - inside box
g.drawLine(3,iconSize-5, iconSize-9,7);
// down,left to up,right - outside box
g.drawLine(iconSize-6,4, iconSize-5,3);
// outside edge of arrow head
g.drawLine(iconSize-7,1, iconSize-7,2);
// outside edge of arrow head
g.drawLine(iconSize-6,1, iconSize-2,1);
// light highlight
g.setColor(ulLightHighlightColor);
// down,left to up,right - inside box
g.drawLine(5,iconSize-4, iconSize-8,9);
g.setColor(lrLightHighlightColor);
g.drawLine(iconSize-6,3, iconSize-4,5); // outside box
g.drawLine(iconSize-4,5, iconSize-4,6); // one down from this
g.drawLine(iconSize-2,7, iconSize-1,7); // outside edge arrow head
g.drawLine(iconSize-1,2, iconSize-1,6); // outside edge arrow head
// main part of arrow
g.setColor(mainItemColor);
g.drawLine(3,iconSize-4, iconSize-3,2); // top edge of staff
g.drawLine(3,iconSize-3, iconSize-2,2); // bottom edge of staff
g.drawLine(4,iconSize-3, 5,iconSize-3); // highlights inside of box
g.drawLine(iconSize-7,8, iconSize-7,9); // highlights inside of box
g.drawLine(iconSize-6,2, iconSize-4,2); // top of arrow head
g.drawRect(iconSize-3,3, 1,3); // right of arrow head
g.translate(-x, -y);
}
|