1 23 24 package org.netbeans.swing.plaf.metal; 25 26 import javax.swing.*; 27 import javax.swing.border.AbstractBorder ; 28 import java.awt.*; 29 30 34 class StatusLineBorder extends AbstractBorder { 35 36 37 public static final int LEFT = 1; 38 public static final int TOP = 2; 39 public static final int RIGHT = 4; 40 41 private Insets insets; 42 43 private int type; 44 45 47 public StatusLineBorder (int type) { 48 this.type = type; 49 } 50 51 public void paintBorder(Component c, Graphics g, int x, int y, 52 int w, int h) { 53 g.translate(x, y); 54 Color shadowC = UIManager.getColor("controlShadow"); Color highlightC = UIManager.getColor("controlHighlight"); Color middleC = UIManager.getColor("control"); if ((type & TOP) != 0) { 59 g.setColor(shadowC); 60 g.drawLine(0, 0, w - 1, 0); 61 g.drawLine(0, 3, w - 1, 3); 62 g.setColor(highlightC); 63 g.drawLine(0, 1, w - 1, 1); 64 g.setColor(middleC); 65 g.drawLine(0, 2, w - 1, 2); 66 } 67 if ((type & LEFT) != 0) { 69 g.setColor(middleC); 70 g.drawLine(0, 2, 0, h - 1); 71 g.setColor(shadowC); 72 g.drawLine(1, 3, 1, h - 1); 73 } 74 if ((type & RIGHT) != 0) { 76 g.setColor(shadowC); 77 g.drawLine(w - 2, 3, w - 2, h - 1); 78 g.setColor(highlightC); 79 g.drawLine(w - 1, 4, w - 1, h - 1); 80 g.setColor(middleC); 81 g.drawLine(w - 1, 3, w - 1, 3); 82 } 83 84 g.translate(-x, -y); 85 } 86 87 public Insets getBorderInsets(Component c) { 88 if (insets == null) { 89 insets = getBorderInsets(c, new Insets(0, 0, 0, 0)); 90 } 91 return insets; 92 } 93 94 public Insets getBorderInsets(Component c, Insets insets) { 95 insets.left = (type & LEFT) != 0 ? 2 : 0; 96 insets.top = (type & TOP) != 0 ? 4 : 0; 97 insets.right = (type & RIGHT) != 0 ? 2 : 0; 98 insets.bottom = 0; 99 return insets; 100 } 101 102 } 103 | Popular Tags |