Border.java 981 B

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