1/*************************************************************************** 2 Title: awtUtilities/Border.java 3 Author: Stefan Berghofer, TU Muenchen 4 5 This class defines a nice 3D border. 6***************************************************************************/ 7 8package awtUtilities; 9 10import java.awt.*; 11 12public class Border extends Panel { 13 int bs; 14 15 public Insets getInsets() { 16 return new Insets(bs*3/2,bs*3/2,bs*3/2,bs*3/2); 17 } 18 19 public Border(Component comp,int s) { 20 setLayout(new GridLayout(1,1)); 21 add(comp); 22 bs=s; 23 } 24 25 public void paint(Graphics g) { 26 int w = getSize().width; 27 int h = getSize().height; 28 int x1[]={0,bs,w-bs,w}, y1[]={0,bs,bs,0}; 29 int x2[]={w,w-bs,w-bs,w}, y2[]={0,bs,h-bs,h}; 30 int y3[]={h,h-bs,h-bs,h}; 31 32 g.setColor(new Color(224,224,224)); 33 g.fillPolygon(y1,y2,4); 34 g.fillPolygon(x1,y1,4); 35 g.setColor(Color.gray); 36 g.fillPolygon(x2,y2,4); 37 g.fillPolygon(x1,y3,4); 38 } 39} 40