1. /*
  2. * @(#)MetalCheckBoxUI.java 1.18 03/12/19
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package javax.swing.plaf.metal;
  8. import javax.swing.*;
  9. import javax.swing.plaf.basic.BasicCheckBoxUI;
  10. import java.awt.*;
  11. import java.awt.event.*;
  12. import javax.swing.plaf.*;
  13. import java.io.Serializable;
  14. /**
  15. * CheckboxUI implementation for MetalCheckboxUI
  16. * <p>
  17. * <strong>Warning:</strong>
  18. * Serialized objects of this class will not be compatible with
  19. * future Swing releases. The current serialization support is
  20. * appropriate for short term storage or RMI between applications running
  21. * the same version of Swing. As of 1.4, support for long term storage
  22. * of all JavaBeans<sup><font size="-2">TM</font></sup>
  23. * has been added to the <code>java.beans</code> package.
  24. * Please see {@link java.beans.XMLEncoder}.
  25. *
  26. * @version 1.18 12/19/03
  27. * @author Michael C. Albers
  28. *
  29. */
  30. public class MetalCheckBoxUI extends MetalRadioButtonUI {
  31. // NOTE: MetalCheckBoxUI inherts from MetalRadioButtonUI instead
  32. // of BasicCheckBoxUI because we want to pick up all the
  33. // painting changes made in MetalRadioButtonUI.
  34. private final static MetalCheckBoxUI checkboxUI = new MetalCheckBoxUI();
  35. private final static String propertyPrefix = "CheckBox" + ".";
  36. private boolean defaults_initialized = false;
  37. // ********************************
  38. // Create PlAF
  39. // ********************************
  40. public static ComponentUI createUI(JComponent b) {
  41. return checkboxUI;
  42. }
  43. public String getPropertyPrefix() {
  44. return propertyPrefix;
  45. }
  46. // ********************************
  47. // Defaults
  48. // ********************************
  49. public void installDefaults(AbstractButton b) {
  50. super.installDefaults(b);
  51. if(!defaults_initialized) {
  52. icon = UIManager.getIcon(getPropertyPrefix() + "icon");
  53. defaults_initialized = true;
  54. }
  55. }
  56. protected void uninstallDefaults(AbstractButton b) {
  57. super.uninstallDefaults(b);
  58. defaults_initialized = false;
  59. }
  60. }