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