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(4,11, iconSize-13,iconSize-13);
// light highlight
g.setColor(lrLightHighlightColor);
g.drawRect(2,10, iconSize-10,iconSize-11); // low,right
g.setColor(ulLightHighlightColor);
g.drawRect(3,10, iconSize-12,iconSize-12); // up,left
// dark highlight
g.setColor(darkHighlightColor);
g.drawRect(1,8, iconSize-10,iconSize-10); // outer
g.drawRect(2,9, iconSize-12,iconSize-12); // inner
// main box
g.setColor(mainItemColor);
g.drawRect(2,9, iconSize-11,iconSize-11);
g.drawLine(iconSize-10,10, iconSize-10,10); // up right highlight
g.drawLine(3,iconSize-3, 3,iconSize-3); // low left highlight
// ARROW
// do the shaft first
g.setColor(mainItemColor);
g.fillRect(iconSize-7,3, 3,5); // do a big block
g.drawLine(iconSize-6,5, iconSize-3,2); // top shaft
g.drawLine(iconSize-6,6, iconSize-2,2); // bottom shaft
g.drawLine(iconSize-6,7, iconSize-3,7); // bottom arrow head
// draw the dark highlight
g.setColor(darkHighlightColor);
g.drawLine(iconSize-8,2, iconSize-7,2); // top of arrowhead
g.drawLine(iconSize-8,3, iconSize-8,7); // left of arrowhead
g.drawLine(iconSize-6,4, iconSize-3,1); // top of shaft
g.drawLine(iconSize-4,6, iconSize-3,6); // top,right of arrowhead
// draw the light highlight
g.setColor(lrLightHighlightColor);
g.drawLine(iconSize-6,3, iconSize-6,3); // top
g.drawLine(iconSize-4,5, iconSize-2,3); // under shaft
g.drawLine(iconSize-7,8, iconSize-3,8); // under arrowhead
g.drawLine(iconSize-2,8, iconSize-2,7); // right of arrowhead
g.translate(-x, -y);
}
|