1. /*
  2. * @(#)WindowsDesktopIconUI.java 1.20 04/04/15
  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.plaf.*;
  10. import javax.swing.plaf.basic.*;
  11. import javax.swing.*;
  12. import javax.swing.border.*;
  13. /**
  14. * Windows icon for a minimized window on the desktop.
  15. * <p>
  16. * <strong>Warning:</strong>
  17. * Serialized objects of this class will not be compatible with
  18. * future Swing releases. The current serialization support is appropriate
  19. * for short term storage or RMI between applications running the same
  20. * version of Swing. A future release of Swing will provide support for
  21. * long term persistence.
  22. */
  23. public class WindowsDesktopIconUI extends BasicDesktopIconUI {
  24. private int width;
  25. public static ComponentUI createUI(JComponent c) {
  26. return new WindowsDesktopIconUI();
  27. }
  28. public void installDefaults() {
  29. super.installDefaults();
  30. width = UIManager.getInt("DesktopIcon.width");
  31. }
  32. public void installUI(JComponent c) {
  33. super.installUI(c);
  34. c.setOpaque(XPStyle.getXP() == null);
  35. }
  36. // Uninstall the listeners added by the WindowsInternalFrameTitlePane
  37. public void uninstallUI(JComponent c) {
  38. WindowsInternalFrameTitlePane thePane =
  39. (WindowsInternalFrameTitlePane)iconPane;
  40. super.uninstallUI(c);
  41. thePane.uninstallListeners();
  42. }
  43. protected void installComponents() {
  44. iconPane = new WindowsInternalFrameTitlePane(frame);
  45. desktopIcon.setLayout(new BorderLayout());
  46. desktopIcon.add(iconPane, BorderLayout.CENTER);
  47. if (XPStyle.getXP() != null) {
  48. desktopIcon.setBorder(null);
  49. }
  50. }
  51. public Dimension getPreferredSize(JComponent c) {
  52. // Windows desktop icons can not be resized. Therefore, we should
  53. // always return the minimum size of the desktop icon. See
  54. // getMinimumSize(JComponent c).
  55. return getMinimumSize(c);
  56. }
  57. /**
  58. * Windows desktop icons are restricted to a width of 160 pixels by
  59. * default. This value is retrieved by the DesktopIcon.width property.
  60. */
  61. public Dimension getMinimumSize(JComponent c) {
  62. Dimension dim = super.getMinimumSize(c);
  63. dim.width = width;
  64. return dim;
  65. }
  66. }