1. /*
  2. * @(#)WindowsDesktopIconUI.java 1.17 03/01/23
  3. *
  4. * Copyright 2003 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. // BasicDesktopIconUI.iconPane should be protected!
  26. private JComponent windowsIconPane;
  27. public static ComponentUI createUI(JComponent c) {
  28. return new WindowsDesktopIconUI();
  29. }
  30. public WindowsDesktopIconUI() {
  31. }
  32. public void installDefaults() {
  33. super.installDefaults();
  34. width = UIManager.getInt("DesktopIcon.width");
  35. }
  36. public void installUI(JComponent c) {
  37. super.installUI(c);
  38. c.setOpaque(XPStyle.getXP() == null);
  39. }
  40. protected void installComponents() {
  41. windowsIconPane = new WindowsInternalFrameTitlePane(frame);
  42. desktopIcon.setLayout(new BorderLayout());
  43. desktopIcon.add(windowsIconPane, BorderLayout.CENTER);
  44. if (XPStyle.getXP() != null) {
  45. desktopIcon.setBorder(null);
  46. }
  47. }
  48. protected void uninstallComponents() {
  49. desktopIcon.remove(windowsIconPane);
  50. desktopIcon.setLayout(null);
  51. windowsIconPane = null;
  52. }
  53. public Dimension getPreferredSize(JComponent c) {
  54. // Windows desktop icons can not be resized. Therefore, we should
  55. // always return the minimum size of the desktop icon. See
  56. // getMinimumSize(JComponent c).
  57. return getMinimumSize(c);
  58. }
  59. public Dimension getMinimumSize(JComponent c) {
  60. // Windows desktop icons are restricted to a width of 160 pixels by
  61. // default. This value is retrieved by the DesktopIcon.width property.
  62. Dimension dim = new Dimension(windowsIconPane.getMinimumSize());
  63. Border border = frame.getBorder();
  64. if (border != null) {
  65. dim.height += border.getBorderInsets(frame).bottom +
  66. border.getBorderInsets(frame).top;
  67. }
  68. dim.width = width;
  69. return dim;
  70. }
  71. public Dimension getMaximumSize(JComponent c) {
  72. // Windows desktop icons can not be resized. Therefore, we should
  73. // always return the minimum size of the desktop icon. See
  74. // getMinimumSize(JComponent c).
  75. return getMinimumSize(c);
  76. }
  77. }