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