1. /*
  2. * @(#)WindowsCheckBoxMenuItemUI.java 1.16 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 com.sun.java.swing.plaf.windows;
  8. import java.awt.*;
  9. import javax.swing.*;
  10. import javax.swing.plaf.*;
  11. import javax.swing.plaf.basic.*;
  12. /**
  13. * Windows check box menu item.
  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 WindowsCheckBoxMenuItemUI extends BasicCheckBoxMenuItemUI {
  23. public static ComponentUI createUI(JComponent b) {
  24. return new WindowsCheckBoxMenuItemUI();
  25. }
  26. /**
  27. * Method which renders the text of the current menu item.
  28. * <p>
  29. * @param g Graphics context
  30. * @param menuItem Current menu item to render
  31. * @param textRect Bounding rectangle to render the text.
  32. * @param text String to render
  33. * @since 1.4
  34. */
  35. protected void paintText(Graphics g, JMenuItem menuItem,
  36. Rectangle textRect, String text) {
  37. ButtonModel model = menuItem.getModel();
  38. Color oldColor = g.getColor();
  39. if(model.isEnabled() && model.isArmed()) {
  40. g.setColor(selectionForeground); // Uses protected field.
  41. }
  42. WindowsGraphicsUtils.paintText(g, menuItem, textRect, text, 0);
  43. g.setColor(oldColor);
  44. }
  45. }