1 7 package javax.swing.border; 8 9 import java.awt.Graphics ; 10 import java.awt.Insets ; 11 import java.awt.Rectangle ; 12 import java.awt.Color ; 13 import java.awt.Component ; 14 15 16 33 public class SoftBevelBorder extends BevelBorder 34 { 35 36 42 public SoftBevelBorder(int bevelType) { 43 super(bevelType); 44 } 45 46 53 public SoftBevelBorder(int bevelType, Color highlight, Color shadow) { 54 super(bevelType, highlight, shadow); 55 } 56 57 66 public SoftBevelBorder(int bevelType, Color highlightOuterColor, 67 Color highlightInnerColor, Color shadowOuterColor, 68 Color shadowInnerColor) { 69 super(bevelType, highlightOuterColor, highlightInnerColor, 70 shadowOuterColor, shadowInnerColor); 71 } 72 73 83 public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { 84 Color oldColor = g.getColor(); 85 g.translate(x, y); 86 87 if (bevelType == RAISED) { 88 g.setColor(getHighlightOuterColor(c)); 89 g.drawLine(0, 0, width-2, 0); 90 g.drawLine(0, 0, 0, height-2); 91 g.drawLine(1, 1, 1, 1); 92 93 g.setColor(getHighlightInnerColor(c)); 94 g.drawLine(2, 1, width-2, 1); 95 g.drawLine(1, 2, 1, height-2); 96 g.drawLine(2, 2, 2, 2); 97 g.drawLine(0, height-1, 0, height-2); 98 g.drawLine(width-1, 0, width-1, 0); 99 100 g.setColor(getShadowOuterColor(c)); 101 g.drawLine(2, height-1, width-1, height-1); 102 g.drawLine(width-1, 2, width-1, height-1); 103 104 g.setColor(getShadowInnerColor(c)); 105 g.drawLine(width-2, height-2, width-2, height-2); 106 107 108 } else if (bevelType == LOWERED) { 109 g.setColor(getShadowOuterColor(c)); 110 g.drawLine(0, 0, width-2, 0); 111 g.drawLine(0, 0, 0, height-2); 112 g.drawLine(1, 1, 1, 1); 113 114 g.setColor(getShadowInnerColor(c)); 115 g.drawLine(2, 1, width-2, 1); 116 g.drawLine(1, 2, 1, height-2); 117 g.drawLine(2, 2, 2, 2); 118 g.drawLine(0, height-1, 0, height-2); 119 g.drawLine(width-1, 0, width-1, 0); 120 121 g.setColor(getHighlightOuterColor(c)); 122 g.drawLine(2, height-1, width-1, height-1); 123 g.drawLine(width-1, 2, width-1, height-1); 124 125 g.setColor(getHighlightInnerColor(c)); 126 g.drawLine(width-2, height-2, width-2, height-2); 127 } 128 g.translate(-x, -y); 129 g.setColor(oldColor); 130 } 131 132 136 public Insets getBorderInsets(Component c) { 137 return getBorderInsets(c, new Insets (0,0,0,0)); 138 } 139 140 145 public Insets getBorderInsets(Component c, Insets insets) { 146 insets.top = insets.left = insets.bottom = insets.right = 3; 147 return insets; 148 } 149 150 153 public boolean isBorderOpaque() { return false; } 154 155 } 156 | Popular Tags |