下面列出了java.awt.SystemColor#controlDkShadow ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
protected static void paintTick(Graphics g, int x, int y, int w, int h) {
Graphics2D g2 = (Graphics2D) g.create();
// on Macs we want the rich dark blue of controlHighlight,
// but on Windows controlDkShadow is better. Let's check both
// and pick one that has sufficient contrast
g2.setColor(SystemColor.controlText);
for (Color color : new Color[] { SystemColor.controlHighlight,
SystemColor.controlDkShadow }) {
float hsbDistance = getHSBDistance(SystemColor.window, color);
if (hsbDistance > 1) {
g2.setColor(color);
break;
}
}
g2.setStroke(new BasicStroke(2.1f));
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL,
RenderingHints.VALUE_STROKE_PURE);
int k = Math.min(w, h) / 5;
int cx = x + w / 2;
int cy = y + h / 2;
if (JVM.isMac) {
// this make the rendering symmetrical; I'm not sure why platforms
// vary
g2.draw(new Line2D.Float(cx - k, cy - k, cx + k, cy + k));
} else {
g2.draw(new Line2D.Float(cx - k, cy - k, cx + k + 1, cy + k + 1));
}
g2.dispose();
}