Java Code Examples for java.awt.SystemColor#controlDkShadow()
The following examples show how to use
java.awt.SystemColor#controlDkShadow() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MixedCheckBoxState.java From pumpernickel with MIT License | 5 votes |
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(); }