1. /*
  2. * @(#)MotifScrollPaneUI.java 1.14 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 com.sun.java.swing.plaf.motif;
  11. import javax.swing.*;
  12. import javax.swing.border.*;
  13. import javax.swing.plaf.*;
  14. import javax.swing.plaf.basic.BasicScrollPaneUI;
  15. /**
  16. * A CDE/Motif L&F implementation of ScrollPaneUI.
  17. * <p>
  18. * <strong>Warning:</strong>
  19. * Serialized objects of this class will not be compatible with
  20. * future Swing releases. The current serialization support is appropriate
  21. * for short term storage or RMI between applications running the same
  22. * version of Swing. A future release of Swing will provide support for
  23. * long term persistence.
  24. *
  25. * @version 1.10 08/28/98
  26. * @author Hans Muller
  27. */
  28. public class MotifScrollPaneUI extends BasicScrollPaneUI
  29. {
  30. private final static Border vsbMarginBorderR = new EmptyBorder(0, 4, 0, 0);
  31. private final static Border vsbMarginBorderL = new EmptyBorder(0, 0, 0, 4);
  32. private final static Border hsbMarginBorder = new EmptyBorder(4, 0, 0, 0);
  33. private Border vsbBorder;
  34. private Border hsbBorder;
  35. protected void installDefaults(JScrollPane scrollpane) {
  36. super.installDefaults(scrollpane);
  37. JScrollBar vsb = scrollpane.getVerticalScrollBar();
  38. if (vsb != null) {
  39. if (MotifGraphicsUtils.isLeftToRight(scrollpane)) {
  40. vsbBorder = new CompoundBorder(vsbMarginBorderR,
  41. vsb.getBorder());
  42. }
  43. else {
  44. vsbBorder = new CompoundBorder(vsbMarginBorderL,
  45. vsb.getBorder());
  46. }
  47. vsb.setBorder(vsbBorder);
  48. }
  49. JScrollBar hsb = scrollpane.getHorizontalScrollBar();
  50. if (hsb != null) {
  51. hsbBorder = new CompoundBorder(hsbMarginBorder, hsb.getBorder());
  52. hsb.setBorder(hsbBorder);
  53. }
  54. }
  55. protected void uninstallDefaults(JScrollPane c) {
  56. super.uninstallDefaults(c);
  57. JScrollBar vsb = scrollpane.getVerticalScrollBar();
  58. if (vsb != null) {
  59. if (vsb.getBorder() == vsbBorder) {
  60. vsb.setBorder(null);
  61. }
  62. vsbBorder = null;
  63. }
  64. JScrollBar hsb = scrollpane.getHorizontalScrollBar();
  65. if (hsb != null) {
  66. if (hsb.getBorder() == hsbBorder) {
  67. hsb.setBorder(null);
  68. }
  69. hsbBorder = null;
  70. }
  71. }
  72. public static ComponentUI createUI(JComponent x) {
  73. return new MotifScrollPaneUI();
  74. }
  75. }