KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > swingwtx > swing > border > AbstractBorder


1 /*
2    SwingWT
3    Copyright(c)2003-2004, R. Rawson-Tetley
4
5    For more information on distributing and using this program, please
6    see the accompanying "COPYING" file.
7
8    Contact me by electronic mail: bobintetley@users.sourceforge.net
9
10    $Log: AbstractBorder.java,v $
11    Revision 1.6 2004/05/03 20:53:45 dannaab
12    small tweak to layoutmanager instance objects to make easier to read
13
14    Revision 1.5 2004/04/30 23:18:26 dannaab
15    List selection support, misc bug fixes
16
17    Revision 1.4 2004/04/23 00:52:32 dannaab
18    Handle borders in a Swing-like way. Implement EmptyBorder & TitledBorder
19
20    Revision 1.3 2003/12/14 09:13:38 bobintetley
21    Added CVS log to source headers
22
23 */

24
25 package swingwtx.swing.border;
26
27 import swingwt.awt.*;
28
29 public abstract class AbstractBorder implements Border {
30
31     public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {}
32     public Insets getBorderInsets(Component c) { Insets insets = new Insets(); return getBorderInsets(c, insets); }
33     public Insets getBorderInsets(Component c, Insets insets) { return insets; }
34     public boolean isBorderOpaque() { return false; }
35     public Rectangle getInteriorRectangle(Component c, int x, int y, int width, int height) {
36         return getInteriorRectangle(c, this, x, y, width, height);
37     }
38     public static Rectangle getInteriorRectangle(Component c, Border b, int x, int y, int width, int height) {
39         Insets insets;
40         if(b != null)
41             insets = b.getBorderInsets(c);
42         else
43             insets = new Insets(0,0,0,0);
44             return new Rectangle( x+insets.left, y+insets.top, width-insets.right-insets.left,
45                                   height-insets.top-insets.bottom);
46     }
47     static boolean isLeftToRight( Component c ) { return c.getComponentOrientation().isLeftToRight(); }
48 }
49
Popular Tags