home *** CD-ROM | disk | FTP | other *** search
/ S283 Planetary Science &n…he Search for Life DVD 2 / DVD-ROM.iso / install / jre1_3 / lib / rt.jar / javax / swing / border / LineBorder.class (.txt) < prev    next >
Encoding:
Java Class File  |  1979-12-31  |  1.6 KB  |  85 lines

  1. package javax.swing.border;
  2.  
  3. import java.awt.Color;
  4. import java.awt.Component;
  5. import java.awt.Graphics;
  6. import java.awt.Insets;
  7.  
  8. public class LineBorder extends AbstractBorder {
  9.    private static Border blackLine;
  10.    private static Border grayLine;
  11.    protected int thickness;
  12.    protected Color lineColor;
  13.    protected boolean roundedCorners;
  14.  
  15.    public static Border createBlackLineBorder() {
  16.       if (blackLine == null) {
  17.          blackLine = new LineBorder(Color.black, 1);
  18.       }
  19.  
  20.       return blackLine;
  21.    }
  22.  
  23.    public static Border createGrayLineBorder() {
  24.       if (grayLine == null) {
  25.          grayLine = new LineBorder(Color.gray, 1);
  26.       }
  27.  
  28.       return grayLine;
  29.    }
  30.  
  31.    public LineBorder(Color var1) {
  32.       this(var1, 1, false);
  33.    }
  34.  
  35.    public LineBorder(Color var1, int var2) {
  36.       this(var1, var2, false);
  37.    }
  38.  
  39.    public LineBorder(Color var1, int var2, boolean var3) {
  40.       this.lineColor = var1;
  41.       this.thickness = var2;
  42.       this.roundedCorners = var3;
  43.    }
  44.  
  45.    public void paintBorder(Component var1, Graphics var2, int var3, int var4, int var5, int var6) {
  46.       Color var7 = var2.getColor();
  47.       var2.setColor(this.lineColor);
  48.  
  49.       for(int var8 = 0; var8 < this.thickness; ++var8) {
  50.          if (!this.roundedCorners) {
  51.             var2.drawRect(var3 + var8, var4 + var8, var5 - var8 - var8 - 1, var6 - var8 - var8 - 1);
  52.          } else {
  53.             var2.drawRoundRect(var3 + var8, var4 + var8, var5 - var8 - var8 - 1, var6 - var8 - var8 - 1, this.thickness, this.thickness);
  54.          }
  55.       }
  56.  
  57.       var2.setColor(var7);
  58.    }
  59.  
  60.    public Insets getBorderInsets(Component var1) {
  61.       return new Insets(this.thickness, this.thickness, this.thickness, this.thickness);
  62.    }
  63.  
  64.    public Insets getBorderInsets(Component var1, Insets var2) {
  65.       var2.left = var2.top = var2.right = var2.bottom = this.thickness;
  66.       return var2;
  67.    }
  68.  
  69.    public Color getLineColor() {
  70.       return this.lineColor;
  71.    }
  72.  
  73.    public int getThickness() {
  74.       return this.thickness;
  75.    }
  76.  
  77.    public boolean getRoundedCorners() {
  78.       return this.roundedCorners;
  79.    }
  80.  
  81.    public boolean isBorderOpaque() {
  82.       return !this.roundedCorners;
  83.    }
  84. }
  85.