KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > swingwtx > swing > plaf > ComponentUI


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: ComponentUI.java,v $
11    Revision 1.2 2004/04/15 11:24:33 bobintetley
12    (Dan Naab) ComponentUI, UIDefaults/UIManager and Accessibility support.
13    (Antonio Weber) TableColumnModelListener implementation and support
14
15
16 */

17
18 package swingwtx.swing.plaf;
19
20 import swingwtx.swing.SwingUtilities;
21 import swingwtx.swing.JComponent;
22 import swingwtx.accessibility.Accessible;
23
24 import swingwt.awt.Graphics;
25 import swingwt.awt.Dimension;
26
27 /**
28  * @author Naab
29  * @version %I%, %G%
30  */

31 public abstract class ComponentUI
32 {
33     /**
34      * createUI - must be implemented by subclasses
35      * Not sure why Sun didn't make this abstract.
36      * @param component
37      * @return
38      */

39     public static ComponentUI createUI(JComponent component)
40     {
41         throw new UnsupportedOperationException JavaDoc(
42                 "createUI(JComponent) must be implemented by final ComponentUI implementation!");
43     }
44
45     // Default ComponentUI install/uninstall - do nothing.
46
public void installUI(JComponent c) {}
47     public void uninstallUI(JComponent c) {}
48
49     public void paint(Graphics g, JComponent c) {}
50     public void update(Graphics g, JComponent c)
51     {
52         if (c.isOpaque())
53         {
54             g.setColor(c.getBackground());
55             g.fillRect(0, 0, c.getWidth(), c.getHeight());
56         }
57         paint(g, c);
58     }
59
60     /** Default component size methods - return null */
61     public Dimension getPreferredSize(JComponent component) { return null; }
62     public Dimension getMinimumSize(JComponent component) { return getPreferredSize(component); }
63     public Dimension getMaximumSize(JComponent component) { return getPreferredSize(component); }
64
65     /**
66      * Should return true if coordinates are inside this component's screen real-estate.
67      * Currently, always returns false because SWT doesn't have this notion.
68      * @param component
69      * @param x
70      * @param y
71      * @return always returns false
72      */

73     // TODO: implement
74
//public boolean contains(JComponent component, int x, int y) { return component.inside(x, y); }
75
public boolean contains(JComponent component, int x, int y) { return false; }
76
77     /** Accessible methods - currently just stubbed out in SwingUtilities */
78     public int getAccessibleChildrenCount(JComponent c) { return SwingUtilities.getAccessibleChildrenCount(c); }
79     public Accessible getAccessibleChild(JComponent c, int i) { return SwingUtilities.getAccessibleChild(c, i); }
80 }
81
Popular Tags