1. /*
  2. * @(#)WindowsRadioButtonUI.java 1.15 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.windows;
  8. import javax.swing.plaf.basic.*;
  9. import javax.swing.*;
  10. import javax.swing.plaf.*;
  11. import java.awt.*;
  12. /**
  13. * Windows rendition of the component.
  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. public class WindowsRadioButtonUI extends BasicRadioButtonUI
  23. {
  24. private static final WindowsRadioButtonUI windowsRadioButtonUI = new WindowsRadioButtonUI();
  25. protected int dashedRectGapX;
  26. protected int dashedRectGapY;
  27. protected int dashedRectGapWidth;
  28. protected int dashedRectGapHeight;
  29. protected Color focusColor;
  30. private boolean initialized = false;
  31. // ********************************
  32. // Create PLAF
  33. // ********************************
  34. public static ComponentUI createUI(JComponent c) {
  35. return windowsRadioButtonUI;
  36. }
  37. // ********************************
  38. // Defaults
  39. // ********************************
  40. public void installDefaults(AbstractButton b) {
  41. super.installDefaults(b);
  42. if(!initialized) {
  43. dashedRectGapX = ((Integer)UIManager.get("Button.dashedRectGapX")).intValue();
  44. dashedRectGapY = ((Integer)UIManager.get("Button.dashedRectGapY")).intValue();
  45. dashedRectGapWidth = ((Integer)UIManager.get("Button.dashedRectGapWidth")).intValue();
  46. dashedRectGapHeight = ((Integer)UIManager.get("Button.dashedRectGapHeight")).intValue();
  47. focusColor = UIManager.getColor(getPropertyPrefix() + "focus");
  48. initialized = true;
  49. }
  50. }
  51. protected Color getFocusColor() {
  52. return focusColor;
  53. }
  54. // ********************************
  55. // Paint Methods
  56. // ********************************
  57. protected void paintFocus(Graphics g, Rectangle textRect, Dimension d){
  58. g.setColor(getFocusColor());
  59. BasicGraphicsUtils.drawDashedRect(g, textRect.x, textRect.y, textRect.width, textRect.height);
  60. }
  61. }