home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 139 / dpcs0999.iso / Web / CFserver / data1.cab / Java / netscape / application / LineBorder.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-04-12  |  2.6 KB  |  106 lines

  1. package netscape.application;
  2.  
  3. import netscape.util.ClassInfo;
  4. import netscape.util.CodingException;
  5. import netscape.util.Decoder;
  6. import netscape.util.Encoder;
  7.  
  8. public class LineBorder extends Border {
  9.    private static Border blackLine;
  10.    private static Border grayLine;
  11.    private Color color;
  12.    static final String colorField = "color";
  13.    private static Class lineBorderClass;
  14.  
  15.    public static Border blackLine() {
  16.       if (blackLine == null) {
  17.          blackLine = new LineBorder(Color.black);
  18.       }
  19.  
  20.       return blackLine;
  21.    }
  22.  
  23.    public static Border grayLine() {
  24.       if (grayLine == null) {
  25.          grayLine = new LineBorder(Color.gray);
  26.       }
  27.  
  28.       return grayLine;
  29.    }
  30.  
  31.    public LineBorder() {
  32.    }
  33.  
  34.    public LineBorder(Color var1) {
  35.       this();
  36.       this.color = var1;
  37.    }
  38.  
  39.    public void setColor(Color var1) {
  40.       this.color = var1;
  41.    }
  42.  
  43.    public Color color() {
  44.       return this.color;
  45.    }
  46.  
  47.    public int leftMargin() {
  48.       return 1;
  49.    }
  50.  
  51.    public int rightMargin() {
  52.       return 1;
  53.    }
  54.  
  55.    public int topMargin() {
  56.       return 1;
  57.    }
  58.  
  59.    public int bottomMargin() {
  60.       return 1;
  61.    }
  62.  
  63.    public void drawInRect(Graphics var1, int var2, int var3, int var4, int var5) {
  64.       var1.setColor(this.color);
  65.       var1.drawRect(var2, var3, var4, var5);
  66.    }
  67.  
  68.    private Class lineBorderClass() {
  69.       if (lineBorderClass == null) {
  70.          lineBorderClass = blackLine().getClass();
  71.       }
  72.  
  73.       return lineBorderClass;
  74.    }
  75.  
  76.    public void describeClassInfo(ClassInfo var1) {
  77.       super.describeClassInfo(var1);
  78.       var1.addClass("netscape.application.LineBorder", 1);
  79.       var1.addField("color", (byte)18);
  80.    }
  81.  
  82.    public void encode(Encoder var1) throws CodingException {
  83.       super.encode(var1);
  84.       var1.encodeObject("color", this.color);
  85.    }
  86.  
  87.    public void decode(Decoder var1) throws CodingException {
  88.       super.decode(var1);
  89.       this.color = (Color)var1.decodeObject("color");
  90.       if (this.getClass() == this.lineBorderClass()) {
  91.          if (this.color == Color.black) {
  92.             var1.replaceObject(blackLine());
  93.          } else {
  94.             if (this.color == Color.gray) {
  95.                var1.replaceObject(grayLine());
  96.             }
  97.  
  98.          }
  99.       }
  100.    }
  101.  
  102.    public void finishDecoding() throws CodingException {
  103.       super.finishDecoding();
  104.    }
  105. }
  106.