1. /*
  2. * @(#)MotifScrollPaneUI.java 1.11 01/11/29
  3. *
  4. * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package com.sun.java.swing.plaf.motif;
  8. import javax.swing.*;
  9. import javax.swing.border.*;
  10. import javax.swing.plaf.*;
  11. import javax.swing.plaf.basic.BasicScrollPaneUI;
  12. /**
  13. * A CDE/Motif L&F implementation of ScrollPaneUI.
  14. * <p>
  15. * <strong>Warning:</strong>
  16. * Serialized objects of this class will not be compatible with
  17. * future Swing releases. The current serialization support is appropriate
  18. * for short term storage or RMI between applications running the same
  19. * version of Swing. A future release of Swing will provide support for
  20. * long term persistence.
  21. *
  22. * @version 1.11 11/29/01
  23. * @author Hans Muller
  24. */
  25. public class MotifScrollPaneUI extends BasicScrollPaneUI
  26. {
  27. private final static Border vsbMarginBorder = new EmptyBorder(0, 4, 0, 0);
  28. private final static Border hsbMarginBorder = new EmptyBorder(4, 0, 0, 0);
  29. private Border vsbBorder;
  30. private Border hsbBorder;
  31. protected void installDefaults(JScrollPane scrollpane) {
  32. super.installDefaults(scrollpane);
  33. JScrollBar vsb = scrollpane.getVerticalScrollBar();
  34. if (vsb != null) {
  35. vsbBorder = new CompoundBorder(vsbMarginBorder, vsb.getBorder());
  36. vsb.setBorder(vsbBorder);
  37. }
  38. JScrollBar hsb = scrollpane.getHorizontalScrollBar();
  39. if (hsb != null) {
  40. hsbBorder = new CompoundBorder(hsbMarginBorder, hsb.getBorder());
  41. hsb.setBorder(hsbBorder);
  42. }
  43. }
  44. protected void uninstallDefaults(JScrollPane c) {
  45. super.uninstallDefaults(c);
  46. JScrollBar vsb = scrollpane.getVerticalScrollBar();
  47. if (vsb != null) {
  48. if (vsb.getBorder() == vsbBorder) {
  49. vsb.setBorder(null);
  50. }
  51. vsbBorder = null;
  52. }
  53. JScrollBar hsb = scrollpane.getHorizontalScrollBar();
  54. if (hsb != null) {
  55. if (hsb.getBorder() == hsbBorder) {
  56. hsb.setBorder(null);
  57. }
  58. hsbBorder = null;
  59. }
  60. }
  61. public static ComponentUI createUI(JComponent x) {
  62. return new MotifScrollPaneUI();
  63. }
  64. }