FileDocCategorySizeDatePackage
BasicDesktopIconUI.javaAPI DocJava SE 5 API8250Fri Aug 26 14:58:04 BST 2005javax.swing.plaf.basic

BasicDesktopIconUI

public class BasicDesktopIconUI extends DesktopIconUI
Basic L&F for a minimized window on a desktop.
version
1.35 12/19/03
author
David Kloba
author
Steve Wilson
author
Rich Schiavi

Fields Summary
protected JInternalFrame$JDesktopIcon
desktopIcon
protected JInternalFrame
frame
protected JComponent
iconPane
The title pane component used in the desktop icon.
MouseInputListener
mouseInputListener
Constructors Summary
public BasicDesktopIconUI()

    
Methods Summary
protected javax.swing.event.MouseInputListenercreateMouseInputListener()

        return new MouseInputHandler();
    
public static javax.swing.plaf.ComponentUIcreateUI(javax.swing.JComponent c)

        return new BasicDesktopIconUI();
    
public voiddeiconize()

        try { frame.setIcon(false); } catch (PropertyVetoException e2) { }
    
public java.awt.InsetsgetInsets(javax.swing.JComponent c)

        JInternalFrame iframe = desktopIcon.getInternalFrame();
	Border border = iframe.getBorder();
	if(border != null)
	    return border.getBorderInsets(iframe);
	
	return new Insets(0,0,0,0);
    
public java.awt.DimensiongetMaximumSize(javax.swing.JComponent c)
Desktop icons can not be resized. Therefore, we should always return the minimum size of the desktop icon.

see
#getMinimumSize

        return iconPane.getMaximumSize();
    
public java.awt.DimensiongetMinimumSize(javax.swing.JComponent c)

        Dimension dim = new Dimension(iconPane.getMinimumSize());
        Border border = frame.getBorder();

        if (border != null) {
            dim.height += border.getBorderInsets(frame).bottom +
                          border.getBorderInsets(frame).top;
        }
        return dim;
    
public java.awt.DimensiongetPreferredSize(javax.swing.JComponent c)

        return desktopIcon.getLayout().preferredLayoutSize(desktopIcon);
    
protected voidinstallComponents()

	iconPane = new BasicInternalFrameTitlePane(frame);
	desktopIcon.setLayout(new BorderLayout());
	desktopIcon.add(iconPane, BorderLayout.CENTER);
    
protected voidinstallDefaults()

        LookAndFeel.installBorder(desktopIcon, "DesktopIcon.border");
        LookAndFeel.installProperty(desktopIcon, "opaque", Boolean.TRUE);
    
protected voidinstallListeners()

	mouseInputListener = createMouseInputListener();
	desktopIcon.addMouseMotionListener(mouseInputListener);
	desktopIcon.addMouseListener(mouseInputListener);
    
public voidinstallUI(javax.swing.JComponent c)

	desktopIcon = (JInternalFrame.JDesktopIcon)c;
	frame = desktopIcon.getInternalFrame();
	installDefaults();
	installComponents();

	// Update icon layout if frame is already iconified
	JInternalFrame f = desktopIcon.getInternalFrame();
	if (f.isIcon() && f.getParent() == null) {
	    JDesktopPane desktop = desktopIcon.getDesktopPane();
	    if (desktop != null) {
		DesktopManager desktopManager = desktop.getDesktopManager();
		if (desktopManager instanceof DefaultDesktopManager) {
		    desktopManager.iconifyFrame(f);
		}
	    }
	}

	installListeners();
	JLayeredPane.putLayer(desktopIcon, JLayeredPane.getLayer(frame));
    
protected voiduninstallComponents()

	desktopIcon.remove(iconPane);
	desktopIcon.setLayout(null);
        iconPane = null;
    
protected voiduninstallDefaults()

        LookAndFeel.uninstallBorder(desktopIcon);
    
protected voiduninstallListeners()

	desktopIcon.removeMouseMotionListener(mouseInputListener);
	desktopIcon.removeMouseListener(mouseInputListener);
        mouseInputListener = null;
    
public voiduninstallUI(javax.swing.JComponent c)

	uninstallDefaults();
	uninstallComponents();

	// Force future UI to relayout icon
	JInternalFrame f = desktopIcon.getInternalFrame();
	if (f.isIcon()) {
	    JDesktopPane desktop = desktopIcon.getDesktopPane();
	    if (desktop != null) {
		DesktopManager desktopManager = desktop.getDesktopManager();
		if (desktopManager instanceof DefaultDesktopManager) {
		    // This will cause DefaultDesktopManager to layout the icon
		    f.putClientProperty("wasIconOnce", null);
		    // Move aside to allow fresh layout of all icons
		    desktopIcon.setLocation(Integer.MIN_VALUE, 0);
		}
	    }
	}

	uninstallListeners();
	frame = null;
	desktopIcon = null;