KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > mail > gui > message > viewer > HeaderSeparatorBorder


1 package org.columba.mail.gui.message.viewer;
2
3 import java.awt.Color JavaDoc;
4 import java.awt.Component JavaDoc;
5 import java.awt.Graphics JavaDoc;
6 import java.awt.Insets JavaDoc;
7
8 import javax.swing.border.AbstractBorder JavaDoc;
9
10 public class HeaderSeparatorBorder extends AbstractBorder JavaDoc {
11
12     protected Color JavaDoc color;
13     
14     public HeaderSeparatorBorder(Color JavaDoc color) {
15         super();
16         
17         this.color = color;
18     }
19
20     /**
21      * Paints the border for the specified component with the specified position
22      * and size.
23      *
24      * @param c
25      * the component for which this border is being painted
26      * @param g
27      * the paint graphics
28      * @param x
29      * the x position of the painted border
30      * @param y
31      * the y position of the painted border
32      * @param width
33      * the width of the painted border
34      * @param height
35      * the height of the painted border
36      */

37     public void paintBorder(Component JavaDoc c, Graphics JavaDoc g, int x, int y, int width,
38             int height) {
39         Color JavaDoc oldColor = g.getColor();
40         g.setColor(color);
41         g.drawLine(x,y+height-1, x+width-1, y+height-1);
42         
43         g.setColor(oldColor);
44     }
45
46     /**
47      * Returns the insets of the border.
48      *
49      * @param c
50      * the component for which this border insets value applies
51      */

52     public Insets JavaDoc getBorderInsets(Component JavaDoc c) {
53         return new Insets JavaDoc(0, 0, 1, 0);
54     }
55
56     /**
57      * Reinitialize the insets parameter with this Border's current Insets.
58      *
59      * @param c
60      * the component for which this border insets value applies
61      * @param insets
62      * the object to be reinitialized
63      */

64     public Insets JavaDoc getBorderInsets(Component JavaDoc c, Insets JavaDoc insets) {
65         insets.left = insets.top = insets.right = insets.bottom = 1;
66         return insets;
67     }
68     
69 }
70
Popular Tags