1. /*
  2. * @(#)WindowsButtonUI.java 1.18 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.windows;
  11. import javax.swing.plaf.basic.*;
  12. import javax.swing.border.*;
  13. import javax.swing.plaf.*;
  14. import javax.swing.*;
  15. import java.awt.*;
  16. /**
  17. * Windows button.
  18. * <p>
  19. * <strong>Warning:</strong>
  20. * Serialized objects of this class will not be compatible with
  21. * future Swing releases. The current serialization support is appropriate
  22. * for short term storage or RMI between applications running the same
  23. * version of Swing. A future release of Swing will provide support for
  24. * long term persistence.
  25. *
  26. * @version 1.18 02/02/00
  27. * @author Jeff Dinkins
  28. *
  29. */
  30. public class WindowsButtonUI extends BasicButtonUI
  31. {
  32. private final static WindowsButtonUI windowsButtonUI = new WindowsButtonUI();
  33. protected int dashedRectGapX;
  34. protected int dashedRectGapY;
  35. protected int dashedRectGapWidth;
  36. protected int dashedRectGapHeight;
  37. protected Color focusColor;
  38. private boolean defaults_initialized = false;
  39. // ********************************
  40. // Create PLAF
  41. // ********************************
  42. public static ComponentUI createUI(JComponent c){
  43. return windowsButtonUI;
  44. }
  45. // ********************************
  46. // Create Listeners
  47. // ********************************
  48. protected BasicButtonListener createButtonListener(AbstractButton b) {
  49. return new WindowsButtonListener(b);
  50. }
  51. // ********************************
  52. // Defaults
  53. // ********************************
  54. protected void installDefaults(AbstractButton b) {
  55. super.installDefaults(b);
  56. if(!defaults_initialized) {
  57. String pp = getPropertyPrefix();
  58. dashedRectGapX = UIManager.getInt(pp + "dashedRectGapX");
  59. dashedRectGapY = UIManager.getInt(pp + "dashedRectGapY");
  60. dashedRectGapWidth = UIManager.getInt(pp + "dashedRectGapWidth");
  61. dashedRectGapHeight = UIManager.getInt(pp + "dashedRectGapHeight");
  62. focusColor = UIManager.getColor(pp + "focus");
  63. defaults_initialized = true;
  64. }
  65. }
  66. protected void uninstallDefaults(AbstractButton b) {
  67. super.uninstallDefaults(b);
  68. defaults_initialized = false;
  69. }
  70. protected Color getFocusColor() {
  71. return focusColor;
  72. }
  73. // ********************************
  74. // Paint Methods
  75. // ********************************
  76. protected void paintFocus(Graphics g, AbstractButton b, Rectangle viewRect, Rectangle textRect, Rectangle iconRect){
  77. // focus painted same color as text on Basic??
  78. int width = b.getWidth();
  79. int height = b.getHeight();
  80. g.setColor(getFocusColor());
  81. BasicGraphicsUtils.drawDashedRect(g, dashedRectGapX, dashedRectGapY,
  82. width - dashedRectGapWidth, height - dashedRectGapHeight);
  83. }
  84. protected void paintButtonPressed(Graphics g, AbstractButton b){
  85. setTextShiftOffset();
  86. }
  87. }