1 19 package org.netbeans.modules.options.ui; 20 21 import java.awt.Graphics ; 22 import java.awt.Insets ; 23 import java.awt.Color ; 24 import java.awt.Component ; 25 import javax.swing.JLabel ; 26 import javax.swing.UIManager ; 27 import javax.swing.border.AbstractBorder ; 28 29 33 public class LoweredBorder extends AbstractBorder { 34 35 private Color darker = getLabelBackgroundColor().darker ().darker (); 36 private Color brighter = getLabelBackgroundColor().brighter ().brighter (); 37 38 public void paintBorder ( 39 Component c, 40 Graphics g, 41 int x, int y, int w, int h 42 ) { 43 Color oldColor = g.getColor (); 44 g.translate (x, y); 45 g.setColor (darker); 46 g.drawLine (0, 0, 0, h - 1); 47 g.drawLine (1, 0, w - 1, 0); 48 g.setColor (brighter); 49 g.drawLine (1, h - 1, w - 1, h - 1); 50 g.drawLine (w - 1, 1, w - 1, h - 2); 51 g.translate (-x, -y); 52 g.setColor (oldColor); 53 } 54 55 public Insets getBorderInsets (Component c) { 56 return new Insets (1, 1, 1, 1); 57 } 58 59 public boolean isBorderOpaque () { 60 return true; 61 } 62 63 private static Color getLabelBackgroundColor() { 64 Color retval = new JLabel ().getBackground (); 65 return (retval != null) ? retval : UIManager.getDefaults().getColor("Label.background"); } 67 } 68 | Popular Tags |