KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > java > swing > plaf > windows > WindowsDesktopIconUI


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
8 package com.sun.java.swing.plaf.windows;
9
10 import java.awt.*;
11 import javax.swing.plaf.*;
12 import javax.swing.plaf.basic.*;
13 import javax.swing.*;
14 import javax.swing.border.*;
15
16
17
18 /**
19  * Windows icon for a minimized window on the desktop.
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 public class WindowsDesktopIconUI extends BasicDesktopIconUI {
29     private int width;
30
31     public static ComponentUI createUI(JComponent c) {
32         return new WindowsDesktopIconUI();
33     }
34
35     public void installDefaults() {
36         super.installDefaults();
37         width = UIManager.getInt("DesktopIcon.width");
38     }
39
40     public void installUI(JComponent c) {
41     super.installUI(c);
42
43     c.setOpaque(XPStyle.getXP() == null);
44     }
45
46     // Uninstall the listeners added by the WindowsInternalFrameTitlePane
47
public void uninstallUI(JComponent c) {
48         WindowsInternalFrameTitlePane thePane =
49                                         (WindowsInternalFrameTitlePane)iconPane;
50         super.uninstallUI(c);
51         thePane.uninstallListeners();
52     }
53
54     protected void installComponents() {
55         iconPane = new WindowsInternalFrameTitlePane(frame);
56         desktopIcon.setLayout(new BorderLayout());
57         desktopIcon.add(iconPane, BorderLayout.CENTER);
58
59     if (XPStyle.getXP() != null) {
60         desktopIcon.setBorder(null);
61     }
62     }
63
64     public Dimension getPreferredSize(JComponent c) {
65         // Windows desktop icons can not be resized. Therefore, we should
66
// always return the minimum size of the desktop icon. See
67
// getMinimumSize(JComponent c).
68
return getMinimumSize(c);
69     }
70
71     /**
72      * Windows desktop icons are restricted to a width of 160 pixels by
73      * default. This value is retrieved by the DesktopIcon.width property.
74      */

75     public Dimension getMinimumSize(JComponent c) {
76         Dimension dim = super.getMinimumSize(c);
77         dim.width = width;
78         return dim;
79     }
80 }
81
Popular Tags