1. /*
  2. * @(#)MetalComboBoxIcon.java 1.12 03/01/23
  3. *
  4. * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package javax.swing.plaf.metal;
  8. import java.awt.*;
  9. import java.awt.event.*;
  10. import javax.swing.*;
  11. import javax.swing.plaf.*;
  12. import javax.swing.border.*;
  13. import java.io.Serializable;
  14. import javax.swing.plaf.basic.BasicComboBoxUI;
  15. /**
  16. * This utility class draws the horizontal bars which indicate a MetalComboBox
  17. *
  18. * @see MetalComboBoxUI
  19. * @version 1.12 01/23/03
  20. * @author Tom Santos
  21. */
  22. public class MetalComboBoxIcon implements Icon, Serializable {
  23. /**
  24. * Paints the horizontal bars for the
  25. */
  26. public void paintIcon(Component c, Graphics g, int x, int y){
  27. JComponent component = (JComponent)c;
  28. int iconWidth = getIconWidth();
  29. g.translate( x, y );
  30. g.setColor( component.isEnabled() ? MetalLookAndFeel.getControlInfo() : MetalLookAndFeel.getControlShadow() );
  31. g.drawLine( 0, 0, iconWidth - 1, 0 );
  32. g.drawLine( 1, 1, 1 + (iconWidth - 3), 1 );
  33. g.drawLine( 2, 2, 2 + (iconWidth - 5), 2 );
  34. g.drawLine( 3, 3, 3 + (iconWidth - 7), 3 );
  35. g.drawLine( 4, 4, 4 + (iconWidth - 9), 4 );
  36. g.translate( -x, -y );
  37. }
  38. /**
  39. * Created a stub to satisfy the interface.
  40. */
  41. public int getIconWidth() { return 10; }
  42. /**
  43. * Created a stub to satisfy the interface.
  44. */
  45. public int getIconHeight() { return 5; }
  46. }