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

BasicInternalFrameUI

public class BasicInternalFrameUI extends InternalFrameUI
A basic L&F implementation of JInternalFrame.
version
1.118 05/18/04
author
David Kloba
author
Rich Schiavi

Fields Summary
protected JInternalFrame
frame
private Handler
handler
protected MouseInputAdapter
borderListener
protected PropertyChangeListener
propertyChangeListener
protected LayoutManager
internalFrameLayout
protected ComponentListener
componentListener
protected MouseInputListener
glassPaneDispatcher
private InternalFrameListener
internalFrameListener
protected JComponent
northPane
protected JComponent
southPane
protected JComponent
westPane
protected JComponent
eastPane
protected BasicInternalFrameTitlePane
titlePane
private static DesktopManager
sharedDesktopManager
private boolean
componentListenerAdded
private Rectangle
parentBounds
private boolean
dragging
protected KeyStroke
openMenuKey
As of Java 2 platform v1.3 this previously undocumented field is no longer used. Key bindings are now defined by the LookAndFeel, please refer to the key bindings specification for further details.
private boolean
keyBindingRegistered
private boolean
keyBindingActive
private static boolean
isDragging
Constructors Summary
public BasicInternalFrameUI(JInternalFrame b)

    
Methods Summary
protected voidactivateFrame(javax.swing.JInternalFrame f)
This method is called when the frame becomes selected. This action is delegated to the desktopManager.

	getDesktopManager().activateFrame(f);
    
protected voidcloseFrame(javax.swing.JInternalFrame f)
This method is called when the user wants to close the frame. The playCloseSound Action is fired. This action is delegated to the desktopManager.

	// Internal Frame Auditory Cue Activation
        BasicLookAndFeel.playSound(frame,"InternalFrame.closeSound");
	// delegate to desktop manager
	getDesktopManager().closeFrame(f);
    
protected javax.swing.event.MouseInputAdaptercreateBorderListener(javax.swing.JInternalFrame w)

        return new BorderListener();
    
protected java.awt.event.ComponentListenercreateComponentListener()

      return getHandler();
    
protected javax.swing.DesktopManagercreateDesktopManager()

      return new DefaultDesktopManager();
    
protected javax.swing.JComponentcreateEastPane(javax.swing.JInternalFrame w)

        return null;
    
protected javax.swing.event.MouseInputListenercreateGlassPaneDispatcher()

        return getHandler();
    
javax.swing.InputMapcreateInputMap(int condition)

	if (condition == JComponent.WHEN_IN_FOCUSED_WINDOW) {
	    Object[] bindings = (Object[])DefaultLookup.get(
                    frame, this, "InternalFrame.windowBindings");

	    if (bindings != null) {
		return LookAndFeel.makeComponentInputMap(frame, bindings);
	    }
	}
	return null;
    
protected voidcreateInternalFrameListener()

        internalFrameListener = getHandler();
    
protected java.awt.LayoutManagercreateLayoutManager()

        return getHandler();
    
protected javax.swing.JComponentcreateNorthPane(javax.swing.JInternalFrame w)

      titlePane = new BasicInternalFrameTitlePane(w);
      return titlePane;
    
protected java.beans.PropertyChangeListenercreatePropertyChangeListener()

        return getHandler();
    
protected javax.swing.JComponentcreateSouthPane(javax.swing.JInternalFrame w)

	return null;
    
public static javax.swing.plaf.ComponentUIcreateUI(javax.swing.JComponent b)


/////////////////////////////////////////////////////////////////////////////
// ComponentUI Interface Implementation methods
/////////////////////////////////////////////////////////////////////////////
            
        return new BasicInternalFrameUI((JInternalFrame)b);
    
protected javax.swing.JComponentcreateWestPane(javax.swing.JInternalFrame w)

        return null;
    
protected voiddeactivateFrame(javax.swing.JInternalFrame f)
This method is called when the frame is no longer selected. This action is delegated to the desktopManager.

	getDesktopManager().deactivateFrame(f);
    
protected voiddeiconifyFrame(javax.swing.JInternalFrame f)
This method is called when the user wants to deiconify the frame. The playRestoreUpSound Action is fired. This action is delegated to the desktopManager.

	// Internal Frame Auditory Cue Activation
	if ( ! f.isMaximum() ) {
	    // This method seems to regularly get called after an
	    // internal frame is maximized. Don't play this sound then.
            BasicLookAndFeel.playSound(frame, "InternalFrame.restoreUpSound");
	}
	// delegate to desktop manager
	getDesktopManager().deiconifyFrame(f);
    
protected voiddeinstallMouseHandlers(javax.swing.JComponent c)

      c.removeMouseListener(borderListener);
      c.removeMouseMotionListener(borderListener);
    
protected javax.swing.DesktopManagergetDesktopManager()
Returns the proper DesktopManager. Calls getDesktopPane() to find the JDesktop component and returns the desktopManager from it. If this fails, it will return a default DesktopManager that should work in arbitrary parents.

	if(frame.getDesktopPane() != null 
	   && frame.getDesktopPane().getDesktopManager() != null)
	    return frame.getDesktopPane().getDesktopManager();
	if(sharedDesktopManager == null)
	  sharedDesktopManager = createDesktopManager();
	return sharedDesktopManager;	
    
public javax.swing.JComponentgetEastPane()

        return eastPane;
    
private javax.swing.plaf.basic.BasicInternalFrameUI$HandlergetHandler()

        if (handler == null) {
            handler = new Handler();
        }
        return handler;
    
javax.swing.InputMapgetInputMap(int condition)

	if (condition == JComponent.WHEN_IN_FOCUSED_WINDOW) {
	    return createInputMap(condition);
	}
	return null;
    
public java.awt.DimensiongetMaximumSize(javax.swing.JComponent x)

        return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
    
public java.awt.DimensiongetMinimumSize(javax.swing.JComponent x)

	if((JComponent)frame == x) {
	    return frame.getLayout().minimumLayoutSize(x);
        }
        return new Dimension(0, 0);
    
public javax.swing.JComponentgetNorthPane()

        return northPane;
    
public java.awt.DimensiongetPreferredSize(javax.swing.JComponent x)

	if((JComponent)frame == x)
	    return frame.getLayout().preferredLayoutSize(x);
        return new Dimension(100, 100);
    
public javax.swing.JComponentgetSouthPane()

        return southPane;
    
public javax.swing.JComponentgetWestPane()

        return westPane;
    
protected voidiconifyFrame(javax.swing.JInternalFrame f)
This method is called when the user wants to iconify the frame. The playMinimizeSound Action is fired. This action is delegated to the desktopManager.

	// Internal Frame Auditory Cue Activation
        BasicLookAndFeel.playSound(frame, "InternalFrame.minimizeSound");
	// delegate to desktop manager
	getDesktopManager().iconifyFrame(f);
    
protected voidinstallComponents()

	setNorthPane(createNorthPane(frame));
	setSouthPane(createSouthPane(frame));
	setEastPane(createEastPane(frame));
	setWestPane(createWestPane(frame));
    
protected voidinstallDefaults()

	Icon frameIcon = frame.getFrameIcon();
        if (frameIcon == null || frameIcon instanceof UIResource) {
            frame.setFrameIcon(UIManager.getIcon("InternalFrame.icon"));
        }

	// Enable the content pane to inherit background color from its
	// parent by setting its background color to null.
	JComponent contentPane = (JComponent) frame.getContentPane();
	if (contentPane != null) {
          Color bg = contentPane.getBackground();
	  if (bg instanceof UIResource)
	    contentPane.setBackground(null);
	}
        frame.setLayout(internalFrameLayout = createLayoutManager());
	frame.setBackground(UIManager.getLookAndFeelDefaults().getColor("control"));

	LookAndFeel.installBorder(frame, "InternalFrame.border");
	
    
protected voidinstallKeyboardActions()

        createInternalFrameListener();
        if (internalFrameListener != null) {
            frame.addInternalFrameListener(internalFrameListener);
        }

        LazyActionMap.installLazyActionMap(frame, BasicInternalFrameUI.class,
            "InternalFrame.actionMap");
    
protected voidinstallListeners()

        borderListener = createBorderListener(frame);
	propertyChangeListener = createPropertyChangeListener();
	frame.addPropertyChangeListener(propertyChangeListener);
        installMouseHandlers(frame);
	glassPaneDispatcher = createGlassPaneDispatcher();
	frame.getGlassPane().addMouseListener(glassPaneDispatcher);
       	frame.getGlassPane().addMouseMotionListener(glassPaneDispatcher);
	componentListener =  createComponentListener();
        if (frame.getParent() != null) {
	  parentBounds = frame.getParent().getBounds();
	}
	if ((frame.getParent() != null) && !componentListenerAdded) {
	  frame.getParent().addComponentListener(componentListener);
	  componentListenerAdded = true;
	}
    
protected voidinstallMouseHandlers(javax.swing.JComponent c)

      c.addMouseListener(borderListener);
      c.addMouseMotionListener(borderListener);
    
public voidinstallUI(javax.swing.JComponent c)


        frame = (JInternalFrame)c;        

	installDefaults();
	installListeners();
	installComponents();
	installKeyboardActions();

        LookAndFeel.installProperty(frame, "opaque", Boolean.TRUE);
    
public final booleanisKeyBindingActive()

      return keyBindingActive;
    
protected final booleanisKeyBindingRegistered()

      return keyBindingRegistered;
    
static voidloadActionMap(javax.swing.plaf.basic.LazyActionMap map)

        map.put(new UIAction("showSystemMenu") {
            public void actionPerformed(ActionEvent evt) {
                JInternalFrame iFrame = (JInternalFrame)evt.getSource();
                if (iFrame.getUI() instanceof BasicInternalFrameUI) {
                    JComponent comp = ((BasicInternalFrameUI)
                        iFrame.getUI()).getNorthPane();
                    if (comp instanceof BasicInternalFrameTitlePane) {
                        ((BasicInternalFrameTitlePane)comp).
                            showSystemMenu();
                    }
                }
            }

            public boolean isEnabled(Object sender){
                if (sender instanceof JInternalFrame) {
                    JInternalFrame iFrame = (JInternalFrame)sender;
                    if (iFrame.getUI() instanceof BasicInternalFrameUI) {
                        return ((BasicInternalFrameUI)iFrame.getUI()).
                            isKeyBindingActive();
                    }
                }
                return false;
            }
        });

        // Set the ActionMap's parent to the Auditory Feedback Action Map
        BasicLookAndFeel.installAudioActionMap(map);
    
protected voidmaximizeFrame(javax.swing.JInternalFrame f)
This method is called when the user wants to maximize the frame. The playMaximizeSound Action is fired. This action is delegated to the desktopManager.

	// Internal Frame Auditory Cue Activation
        BasicLookAndFeel.playSound(frame,"InternalFrame.maximizeSound");
	// delegate to desktop manager
	getDesktopManager().maximizeFrame(f);
    
protected voidminimizeFrame(javax.swing.JInternalFrame f)
This method is called when the user wants to minimize the frame. The playRestoreDownSound Action is fired. This action is delegated to the desktopManager.

	// Internal Frame Auditory Cue Activation
	if ( ! f.isIcon() ) {
	    // This method seems to regularly get called after an
	    // internal frame is iconified. Don't play this sound then.
            BasicLookAndFeel.playSound(frame,"InternalFrame.restoreDownSound");
	}
	// delegate to desktop manager
	getDesktopManager().minimizeFrame(f);
    
protected voidreplacePane(javax.swing.JComponent currentPane, javax.swing.JComponent newPane)
Installs necessary mouse handlers on newPane and adds it to the frame. Reverse process for the currentPane.

        if(currentPane != null) {
            deinstallMouseHandlers(currentPane);
            frame.remove(currentPane);
        }
        if(newPane != null) {
           frame.add(newPane);
           installMouseHandlers(newPane);
        }
    
public voidsetEastPane(javax.swing.JComponent c)

        eastPane = c;
    
protected final voidsetKeyBindingActive(boolean b)

      keyBindingActive = b;
    
protected final voidsetKeyBindingRegistered(boolean b)

      keyBindingRegistered = b;
    
public voidsetNorthPane(javax.swing.JComponent c)

        if (northPane != null &&
                northPane instanceof BasicInternalFrameTitlePane) {
            ((BasicInternalFrameTitlePane)northPane).uninstallListeners();
        }
        replacePane(northPane, c);
        northPane = c;
    
public voidsetSouthPane(javax.swing.JComponent c)

        southPane = c;
    
public voidsetWestPane(javax.swing.JComponent c)

        westPane = c;
    
protected voidsetupMenuCloseKey()

    
protected voidsetupMenuOpenKey()

	// PENDING(hania): Why are these WHEN_IN_FOCUSED_WINDOWs? Shouldn't
	// they be WHEN_ANCESTOR_OF_FOCUSED_COMPONENT?
	// Also, no longer registering on the desktopicon, the previous
	// action did nothing.
	InputMap map = getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
	SwingUtilities.replaceUIInputMap(frame,
				      JComponent.WHEN_IN_FOCUSED_WINDOW, map);
	//ActionMap actionMap = getActionMap();
	//SwingUtilities.replaceUIActionMap(frame, actionMap);
    
protected voiduninstallComponents()

	setNorthPane(null);
	setSouthPane(null);
	setEastPane(null);
	setWestPane(null);
        if(titlePane != null) {
            titlePane.uninstallDefaults();
        }
        titlePane = null;
    
protected voiduninstallDefaults()

	Icon frameIcon = frame.getFrameIcon();
        if (frameIcon instanceof UIResource) {
            frame.setFrameIcon(null);
        }
        internalFrameLayout = null;
        frame.setLayout(null);
	LookAndFeel.uninstallBorder(frame);
    
protected voiduninstallKeyboardActions()

        if (internalFrameListener != null) {
	    frame.removeInternalFrameListener(internalFrameListener);
        }
        internalFrameListener = null;

	SwingUtilities.replaceUIInputMap(frame, JComponent.
					 WHEN_IN_FOCUSED_WINDOW, null);
	SwingUtilities.replaceUIActionMap(frame, null);

    
protected voiduninstallListeners()

      if ((frame.getParent() != null) && componentListenerAdded) {
	frame.getParent().removeComponentListener(componentListener);
	componentListenerAdded = false;
      }
      componentListener = null;
      frame.getGlassPane().removeMouseListener(glassPaneDispatcher);
      frame.getGlassPane().removeMouseMotionListener(glassPaneDispatcher);
      glassPaneDispatcher = null;
      deinstallMouseHandlers(frame);      
      frame.removePropertyChangeListener(propertyChangeListener);
      propertyChangeListener = null;
      borderListener = null;
    
public voiduninstallUI(javax.swing.JComponent c)

        if(c != frame)
            throw new IllegalComponentStateException(
                this + " was asked to deinstall() " 
                + c + " when it only knows about " 
                + frame + "."); 
                
	uninstallKeyboardActions();
	uninstallComponents();
	uninstallListeners();
	uninstallDefaults();
	frame.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));	
        handler = null;
        frame = null;