01: /*
02: * Copyright 1997-2004 Sun Microsystems, Inc. All Rights Reserved.
03: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
04: *
05: * This code is free software; you can redistribute it and/or modify it
06: * under the terms of the GNU General Public License version 2 only, as
07: * published by the Free Software Foundation. Sun designates this
08: * particular file as subject to the "Classpath" exception as provided
09: * by Sun in the LICENSE file that accompanied this code.
10: *
11: * This code is distributed in the hope that it will be useful, but WITHOUT
12: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14: * version 2 for more details (a copy is included in the LICENSE file that
15: * accompanied this code).
16: *
17: * You should have received a copy of the GNU General Public License version
18: * 2 along with this work; if not, write to the Free Software Foundation,
19: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20: *
21: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22: * CA 95054 USA or visit www.sun.com if you need additional information or
23: * have any questions.
24: */
25:
26: package com.sun.java.swing.plaf.windows;
27:
28: import java.awt.*;
29: import javax.swing.plaf.*;
30: import javax.swing.plaf.basic.*;
31: import javax.swing.*;
32: import javax.swing.border.*;
33:
34: /**
35: * Windows icon for a minimized window on the desktop.
36: * <p>
37: * <strong>Warning:</strong>
38: * Serialized objects of this class will not be compatible with
39: * future Swing releases. The current serialization support is appropriate
40: * for short term storage or RMI between applications running the same
41: * version of Swing. A future release of Swing will provide support for
42: * long term persistence.
43: */
44: public class WindowsDesktopIconUI extends BasicDesktopIconUI {
45: private int width;
46:
47: public static ComponentUI createUI(JComponent c) {
48: return new WindowsDesktopIconUI();
49: }
50:
51: public void installDefaults() {
52: super .installDefaults();
53: width = UIManager.getInt("DesktopIcon.width");
54: }
55:
56: public void installUI(JComponent c) {
57: super .installUI(c);
58:
59: c.setOpaque(XPStyle.getXP() == null);
60: }
61:
62: // Uninstall the listeners added by the WindowsInternalFrameTitlePane
63: public void uninstallUI(JComponent c) {
64: WindowsInternalFrameTitlePane thePane = (WindowsInternalFrameTitlePane) iconPane;
65: super .uninstallUI(c);
66: thePane.uninstallListeners();
67: }
68:
69: protected void installComponents() {
70: iconPane = new WindowsInternalFrameTitlePane(frame);
71: desktopIcon.setLayout(new BorderLayout());
72: desktopIcon.add(iconPane, BorderLayout.CENTER);
73:
74: if (XPStyle.getXP() != null) {
75: desktopIcon.setBorder(null);
76: }
77: }
78:
79: public Dimension getPreferredSize(JComponent c) {
80: // Windows desktop icons can not be resized. Therefore, we should
81: // always return the minimum size of the desktop icon. See
82: // getMinimumSize(JComponent c).
83: return getMinimumSize(c);
84: }
85:
86: /**
87: * Windows desktop icons are restricted to a width of 160 pixels by
88: * default. This value is retrieved by the DesktopIcon.width property.
89: */
90: public Dimension getMinimumSize(JComponent c) {
91: Dimension dim = super.getMinimumSize(c);
92: dim.width = width;
93: return dim;
94: }
95: }
|