1. /*
  2. * @(#)IconUIResource.java 1.9 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 javax.swing.plaf;
  8. import java.awt.Component;
  9. import java.awt.Graphics;
  10. import java.io.Serializable;
  11. import javax.swing.Icon;
  12. import javax.swing.plaf.UIResource;
  13. /*
  14. * An Icon wrapper class which implements UIResource. UI
  15. * classes which set icon properties should use this class
  16. * to wrap any icons specified as defaults.
  17. *
  18. * This class delegates all method invocations to the
  19. * Icon "delegate" object specified at construction.
  20. * <p>
  21. * <strong>Warning:</strong>
  22. * Serialized objects of this class will not be compatible with
  23. * future Swing releases. The current serialization support is appropriate
  24. * for short term storage or RMI between applications running the same
  25. * version of Swing. A future release of Swing will provide support for
  26. * long term persistence.
  27. *
  28. * @see javax.swing.plaf.UIResource
  29. * @version 1.9 11/29/01
  30. * @author Amy Fowler
  31. *
  32. */
  33. public class IconUIResource implements Icon, UIResource, Serializable
  34. {
  35. private Icon delegate;
  36. /**
  37. * Creates a UIResource icon object which wraps
  38. * an existing Icon instance.
  39. * @param delegate the icon being wrapped
  40. */
  41. public IconUIResource(Icon delegate) {
  42. if (delegate == null) {
  43. throw new IllegalArgumentException("null delegate icon argument");
  44. }
  45. this.delegate = delegate;
  46. }
  47. public void paintIcon(Component c, Graphics g, int x, int y) {
  48. delegate.paintIcon(c, g, x, y);
  49. }
  50. public int getIconWidth() {
  51. return delegate.getIconWidth();
  52. }
  53. public int getIconHeight() {
  54. return delegate.getIconHeight();
  55. }
  56. }