KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > swing > plaf > metal > MetalComboBoxIcon


1 /*
2  * @(#)MetalComboBoxIcon.java 1.13 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.metal;
9
10 import java.awt.*;
11 import java.awt.event.*;
12 import javax.swing.*;
13 import javax.swing.plaf.*;
14 import javax.swing.border.*;
15 import java.io.Serializable JavaDoc;
16 import javax.swing.plaf.basic.BasicComboBoxUI JavaDoc;
17
18
19 /**
20  * This utility class draws the horizontal bars which indicate a MetalComboBox
21  *
22  * @see MetalComboBoxUI
23  * @version 1.13 12/19/03
24  * @author Tom Santos
25  */

26 public class MetalComboBoxIcon implements Icon, Serializable JavaDoc {
27      
28     /**
29      * Paints the horizontal bars for the
30      */

31     public void paintIcon(Component c, Graphics g, int x, int y){
32         JComponent component = (JComponent)c;
33     int iconWidth = getIconWidth();
34
35     g.translate( x, y );
36
37     g.setColor( component.isEnabled() ? MetalLookAndFeel.getControlInfo() : MetalLookAndFeel.getControlShadow() );
38     g.drawLine( 0, 0, iconWidth - 1, 0 );
39     g.drawLine( 1, 1, 1 + (iconWidth - 3), 1 );
40     g.drawLine( 2, 2, 2 + (iconWidth - 5), 2 );
41     g.drawLine( 3, 3, 3 + (iconWidth - 7), 3 );
42     g.drawLine( 4, 4, 4 + (iconWidth - 9), 4 );
43
44     g.translate( -x, -y );
45     }
46     
47     /**
48      * Created a stub to satisfy the interface.
49      */

50     public int getIconWidth() { return 10; }
51
52     /**
53      * Created a stub to satisfy the interface.
54      */

55     public int getIconHeight() { return 5; }
56
57 }
58
Popular Tags