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. package javax.swing.plaf.basic;
  8. import javax.swing.*;
  9. import java.awt.Color;
  10. import java.awt.Dimension;
  11. import java.awt.Graphics;
  12. import java.awt.Insets;
  13. import java.awt.Rectangle;
  14. import javax.swing.plaf.ComponentUI;
  15. import javax.swing.plaf.SeparatorUI;
  16. /**
  17. * A Basic L&F implementation of SeparatorUI. This implementation
  18. * is a "combined" view/controller.
  19. *
  20. * @version 1.24 12/19/03
  21. * @author Georges Saab
  22. * @author Jeff Shapiro
  23. */
  24. public class BasicSeparatorUI extends SeparatorUI
  25. {
  26. protected Color shadow;
  27. protected Color highlight;
  28. public static ComponentUI createUI( JComponent c )
  29. {
  30. return new BasicSeparatorUI();
  31. }
  32. public void installUI( JComponent c )
  33. {
  34. installDefaults( (JSeparator)c );
  35. installListeners( (JSeparator)c );
  36. }
  37. public void uninstallUI(JComponent c)
  38. {
  39. uninstallDefaults( (JSeparator)c );
  40. uninstallListeners( (JSeparator)c );
  41. }
  42. protected void installDefaults( JSeparator s )
  43. {
  44. LookAndFeel.installColors( s, "Separator.background", "Separator.foreground" );
  45. LookAndFeel.installProperty( s, "opaque", Boolean.FALSE);
  46. }
  47. protected void uninstallDefaults( JSeparator s )
  48. {
  49. }
  50. protected void installListeners( JSeparator s )
  51. {
  52. }
  53. protected void uninstallListeners( JSeparator s )
  54. {
  55. }
  56. public void paint( Graphics g, JComponent c )
  57. {
  58. Dimension s = c.getSize();
  59. if ( ((JSeparator)c).getOrientation() == JSeparator.VERTICAL )
  60. {
  61. g.setColor( c.getForeground() );
  62. g.drawLine( 0, 0, 0, s.height );
  63. g.setColor( c.getBackground() );
  64. g.drawLine( 1, 0, 1, s.height );
  65. }
  66. else // HORIZONTAL
  67. {
  68. g.setColor( c.getForeground() );
  69. g.drawLine( 0, 0, s.width, 0 );
  70. g.setColor( c.getBackground() );
  71. g.drawLine( 0, 1, s.width, 1 );
  72. }
  73. }
  74. public Dimension getPreferredSize( JComponent c )
  75. {
  76. if ( ((JSeparator)c).getOrientation() == JSeparator.VERTICAL )
  77. return new Dimension( 2, 0 );
  78. else
  79. return new Dimension( 0, 2 );
  80. }
  81. public Dimension getMinimumSize( JComponent c ) { return null; }
  82. public Dimension getMaximumSize( JComponent c ) { return null; }
  83. }