KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > swing > plaf > basic > BasicSeparatorUI


1 /*
2  * @(#)BasicSeparatorUI.java 1.24 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package javax.swing.plaf.basic;
9
10 import javax.swing.*;
11 import java.awt.Color JavaDoc;
12 import java.awt.Dimension JavaDoc;
13 import java.awt.Graphics JavaDoc;
14 import java.awt.Insets JavaDoc;
15 import java.awt.Rectangle JavaDoc;
16 import javax.swing.plaf.ComponentUI JavaDoc;
17 import javax.swing.plaf.SeparatorUI JavaDoc;
18
19
20 /**
21  * A Basic L&F implementation of SeparatorUI. This implementation
22  * is a "combined" view/controller.
23  *
24  * @version 1.24 12/19/03
25  * @author Georges Saab
26  * @author Jeff Shapiro
27  */

28
29 public class BasicSeparatorUI extends SeparatorUI JavaDoc
30 {
31     protected Color JavaDoc shadow;
32     protected Color JavaDoc highlight;
33
34     public static ComponentUI JavaDoc createUI( JComponent c )
35     {
36         return new BasicSeparatorUI JavaDoc();
37     }
38
39     public void installUI( JComponent c )
40     {
41         installDefaults( (JSeparator)c );
42         installListeners( (JSeparator)c );
43     }
44
45     public void uninstallUI(JComponent c)
46     {
47         uninstallDefaults( (JSeparator)c );
48         uninstallListeners( (JSeparator)c );
49     }
50
51     protected void installDefaults( JSeparator s )
52     {
53         LookAndFeel.installColors( s, "Separator.background", "Separator.foreground" );
54         LookAndFeel.installProperty( s, "opaque", Boolean.FALSE);
55     }
56
57     protected void uninstallDefaults( JSeparator s )
58     {
59     }
60
61     protected void installListeners( JSeparator s )
62     {
63     }
64
65     protected void uninstallListeners( JSeparator s )
66     {
67     }
68
69     public void paint( Graphics JavaDoc g, JComponent c )
70     {
71         Dimension JavaDoc s = c.getSize();
72
73     if ( ((JSeparator)c).getOrientation() == JSeparator.VERTICAL )
74     {
75       g.setColor( c.getForeground() );
76       g.drawLine( 0, 0, 0, s.height );
77
78       g.setColor( c.getBackground() );
79       g.drawLine( 1, 0, 1, s.height );
80     }
81     else // HORIZONTAL
82
{
83       g.setColor( c.getForeground() );
84       g.drawLine( 0, 0, s.width, 0 );
85
86       g.setColor( c.getBackground() );
87       g.drawLine( 0, 1, s.width, 1 );
88     }
89     }
90
91     public Dimension JavaDoc getPreferredSize( JComponent c )
92     {
93     if ( ((JSeparator)c).getOrientation() == JSeparator.VERTICAL )
94         return new Dimension JavaDoc( 2, 0 );
95     else
96         return new Dimension JavaDoc( 0, 2 );
97     }
98
99     public Dimension JavaDoc getMinimumSize( JComponent c ) { return null; }
100     public Dimension JavaDoc getMaximumSize( JComponent c ) { return null; }
101 }
102
103
104
105
106
Popular Tags