1 19 20 package org.netbeans.modules.xml.wsdl.ui.view.grapheditor.border; 21 22 import java.awt.Color ; 23 import java.awt.Graphics2D ; 24 import java.awt.Insets ; 25 import java.awt.Paint ; 26 import java.awt.Rectangle ; 27 import org.netbeans.api.visual.border.Border; 28 29 33 public class ButtonBorder implements Border { 34 private int top; 35 private int left; 36 private int bottom; 37 private int right; 38 39 public ButtonBorder(int top, int left, int bottom, int right) { 40 this.top = top; 41 this.left = left; 42 this.bottom = bottom; 43 this.right = right; 44 } 45 46 public Insets getInsets() { 47 return new Insets (top, left, bottom, right); 48 } 49 50 public void paint(Graphics2D g2, Rectangle rect) { 51 Paint oldPaint = g2.getPaint(); 52 53 g2.setPaint(BUTTON_BORDER_COLOR); 54 g2.fillRect(rect.x, rect.y, rect.width, rect.height); 55 g2.setPaint(BUTTON_BACKGROUND_COLOR); 56 g2.fillRect(rect.x + 1, rect.y + 1, rect.width - 2, rect.height - 2); 57 58 g2.setPaint(oldPaint); 59 } 60 61 public boolean isOpaque() { 62 return true; 63 } 64 65 66 public static ButtonBorder createTextButtonBorder() { 67 return new ButtonBorder(2, 8, 2, 8); 68 } 69 70 71 public static ButtonBorder createImageButtonBorder() { 72 return new ButtonBorder(2, 2, 2, 2); 73 } 74 75 76 private static final Color BUTTON_BORDER_COLOR = new Color (0x7F9DB9); 77 private static final Color BUTTON_BACKGROUND_COLOR = new Color (0xEBEBE4); 78 } 79 | Popular Tags |