1. /*
  2. * @(#)WindowsToggleButtonUI.java 1.17 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.plaf.*;
  13. import javax.swing.*;
  14. import java.awt.*;
  15. /**
  16. * A Windows toggle button.
  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.17 02/02/00
  26. * @author Jeff Dinkins
  27. */
  28. public class WindowsToggleButtonUI extends BasicToggleButtonUI
  29. {
  30. protected static int dashedRectGapX;
  31. protected static int dashedRectGapY;
  32. protected static int dashedRectGapWidth;
  33. protected static int dashedRectGapHeight;
  34. protected Color focusColor;
  35. private final static WindowsToggleButtonUI windowsToggleButtonUI = new WindowsToggleButtonUI();
  36. private boolean defaults_initialized = false;
  37. public static ComponentUI createUI(JComponent b) {
  38. return windowsToggleButtonUI;
  39. }
  40. // ********************************
  41. // Defaults
  42. // ********************************
  43. protected void installDefaults(AbstractButton b) {
  44. super.installDefaults(b);
  45. if(!defaults_initialized) {
  46. String pp = getPropertyPrefix();
  47. dashedRectGapX = ((Integer)UIManager.get("Button.dashedRectGapX")).intValue();
  48. dashedRectGapY = ((Integer)UIManager.get("Button.dashedRectGapY")).intValue();
  49. dashedRectGapWidth = ((Integer)UIManager.get("Button.dashedRectGapWidth")).intValue();
  50. dashedRectGapHeight = ((Integer)UIManager.get("Button.dashedRectGapHeight")).intValue();
  51. focusColor = UIManager.getColor(pp + "focus");
  52. defaults_initialized = true;
  53. }
  54. }
  55. protected void uninstallDefaults(AbstractButton b) {
  56. super.uninstallDefaults(b);
  57. defaults_initialized = false;
  58. }
  59. protected Color getFocusColor() {
  60. return focusColor;
  61. }
  62. // ********************************
  63. // Paint Methods
  64. // ********************************
  65. protected void paintFocus(Graphics g, AbstractButton b,
  66. Rectangle viewRect, Rectangle textRect, Rectangle iconRect) {
  67. g.setColor(getFocusColor());
  68. BasicGraphicsUtils.drawDashedRect(g, dashedRectGapX, dashedRectGapY,
  69. b.getWidth() - dashedRectGapWidth,
  70. b.getHeight() - dashedRectGapHeight);
  71. }
  72. }