A bunch of fixes to make JInternalFrame pass both Mauve and Intel's
testsuite.

2006-06-23  Roman Kennke  <[EMAIL PROTECTED]>

        * javax/swing/JInternalFrame.java
        (maxTransition): Removed.
        (JInternalFrame): Set maxium=false. Initialize desktopIcon here.
        Don't initialize storedBounds here.
        (dipose): Rewritten to correctly dispose the JInternalFrame.
        (getDesktopIcon): Don't initialize desktopIcon here.
        (getLayer): Delegate to JLayeredPane.getLayer().
        (getNormalBounds): Return bounds when storedBounds == null,
        otherwise storedBounds.
        (hide): Don't change selection. Also hide the desktopIcon.
        (moveToBack): Call getParent() only once.
        (moveToFront): Call getParent() only once.
        (pack): Call validate() to make sure that the layout is
        propagated to the children.
        (setClosed): Fire InternalFrameEvent first, before the
        PropertyVetoEvent.
        (setJMenuBar): Fire PropertyChangeEvent for this property.
        (setLayer): Delegate to JLayeredPane.
        (setLayeredPane): Check for null and throw
IllegalArgumenException.
        (setMaximum): Remove handling of maxTransition and normalBounds.
        Should probably be done in the UI.
        (setNormalBounds): Store Rectangle object directly, not a copy.
        (setRootPane): Go into rootPaneCheckingEnabled mode so that
        adding the RootPane doesn't add it to the contentPane.
        Fire PropertyChangeEvent.
        (setSelected): Added condition for when this property must not
        be changed.
        (show): Don't ask the DesktopPane to select the frame. Moved
        code around to fire InternalFrameEvent before actually calling
        super.show(). Also make the desktopIcon visible.
        (setTitle): Fire PropertyChangeEvent unconditionally.


/Roman

-- 
“Improvement makes straight roads, but the crooked roads, without
Improvement, are roads of Genius.” - William Blake
Index: javax/swing/JInternalFrame.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/JInternalFrame.java,v
retrieving revision 1.34
diff -u -2 -0 -r1.34 JInternalFrame.java
--- javax/swing/JInternalFrame.java	18 Apr 2006 17:07:56 -0000	1.34
+++ javax/swing/JInternalFrame.java	23 Jun 2006 12:23:57 -0000
@@ -21,43 +21,45 @@
 Linking this library statically or dynamically with other modules is
 making a combined work based on this library.  Thus, the terms and
 conditions of the GNU General Public License cover the whole
 combination.
 
 As a special exception, the copyright holders of this library give you
 permission to link this library with independent modules to produce an
 executable, regardless of the license terms of these independent
 modules, and to copy and distribute the resulting executable under
 terms of your choice, provided that you also meet, for each linked
 independent module, the terms and conditions of the license of that
 module.  An independent module is a module which is not derived from
 or based on this library.  If you modify this library, you may extend
 this exception to your version of the library, but you are not
 obligated to do so.  If you do not wish to do so, delete this
 exception statement from your version. */
 
 
 package javax.swing;
 
+import java.awt.BorderLayout;
 import java.awt.Component;
 import java.awt.Container;
 import java.awt.Graphics;
+import java.awt.IllegalComponentStateException;
 import java.awt.KeyboardFocusManager;
 import java.awt.LayoutManager;
 import java.awt.Rectangle;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyVetoException;
 
 import javax.accessibility.Accessible;
 import javax.accessibility.AccessibleContext;
 import javax.accessibility.AccessibleRole;
 import javax.accessibility.AccessibleValue;
 import javax.swing.event.InternalFrameEvent;
 import javax.swing.event.InternalFrameListener;
 import javax.swing.plaf.DesktopIconUI;
 import javax.swing.plaf.InternalFrameUI;
 
 /**
  * This class implements a Swing widget that looks and acts like a native
  * frame. The frame can be dragged, resized, closed, etc. Typically,
  * JInternalFrames are placed in JDesktopPanes. The actions that the
  * JInternalFrame performs (maximizing, minimizing, etc.) are performed by a
@@ -473,46 +475,40 @@
   protected Icon frameIcon;
 
   /** The rootPane of the JInternalFrame. */
   protected JRootPane rootPane;
 
   /** The title on the TitlePane of the JInternalFrame. */
   protected String title;
 
   /** The bounds of the JInternalFrame before it was maximized. */
   private transient Rectangle storedBounds;
 
   /** The Component that receives focus by default. */
   private transient Component defaultFocus;
 
   /** The default close action taken, */
   private transient int defaultCloseOperation = DISPOSE_ON_CLOSE;
 
   /** Whether the JInternalFrame has become visible for the very first time. */
   private transient boolean isFirstTimeVisible = true;
 
-  /**
-   * Whether the JInternalFrame is in the transition from being a maximized
-   * frame back to a regular sized frame.
-   */
-  private transient boolean maxTransition = false;
-
   /** DOCUMENT ME! */
   private transient boolean wasIcon = false;
 
   /**
    * Creates a new JInternalFrame object that has an empty string for its 
    * title, and is non-resizable, non-maximizable, non-iconifiable, and 
    * non-closable.
    */
   public JInternalFrame()
   {
     this("", false, false, false, false);
   }
 
   /**
    * Creates a new JInternalFrame object with the given title and is
    * non-resizable, non-maximizable, non-iconifiable, and non-closable.
    *
    * @param title The title displayed in the JInternalFrame.
    */
   public JInternalFrame(String title)
@@ -564,45 +560,46 @@
   }
 
   /**
    * Creates a new JInternalFrame object with the given title, resizable,
    * closable, maximizable and iconifiable properties.
    *
    * @param title The title displayed in the JInternalFrame.
    * @param resizable Whether the JInternalFrame is resizable.
    * @param closable Whether the JInternalFrame is closable.
    * @param maximizable Whether the JInternalFrame is maximizable.
    * @param iconifiable Whether the JInternalFrame is iconifiable.
    */
   public JInternalFrame(String title, boolean resizable, boolean closable,
                         boolean maximizable, boolean iconifiable)
   {
     this.title = title;
     this.resizable = resizable;
     this.closable = closable;
     this.maximizable = maximizable;
     this.iconable = iconifiable;
-    storedBounds = new Rectangle();
+    isMaximum = false;
     setRootPane(createRootPane());
     // JInternalFrames are invisible and opaque by default.
     setVisible(false);
     setOpaque(true);
+    desktopIcon = new JDesktopIcon(this);
     updateUI();
     setRootPaneCheckingEnabled(true); // Done the init stage, now adds go to content pane.
   }
 
   /**
    * This method adds Components to this Container. For JInternalFrames,
    * instead of calling add directly on the JInternalFrame, it should be
    * called with JInternalFrame.getContentPane().add. If root pane checking
    * is enabled, calling this method will cause an exception to be thrown.
    *
    * @param comp The Component to add.
    * @param constraints The constraints on the Component added.
    * @param index The position to place the Component.
    *
    * @throws Error DOCUMENT ME!
    */
   protected void addImpl(Component comp, Object constraints, int index)
   {
     // If we're in the initialization stage use super.add. Here we add the
     // rootPane as well as the title bar and other stuff.
@@ -626,58 +623,59 @@
   /**
    * This method is used to create a root pane for the JInternalFrame. This
    * method is called by the constructors.
    *
    * @return A root pane for the JInternalFrame to use.
    */
   protected JRootPane createRootPane()
   {
     return new JRootPane();
   }
 
   /**
    * This method makes this JInternalFrame invisible, unselected and closed.
    * If this JInternalFrame is not closed already, it will fire an
    * INTERNAL_FRAME_CLoSED event. This method is similar to setClosed but it
    * doesn't give vetoable listeners a chance to veto and it will not fire an
    * INTERNAL_FRAME_CLOSING event.
    */
   public void dispose()
   {
-    setVisible(false);
-    JDesktopPane pane = getDesktopPane();
-    if (pane != null)
-      pane.setSelectedFrame(null);
-    else
+    if (isVisible())
+      setVisible(false);
+    if (isSelected())
       {
-	try
-	  {
-	    setSelected(false);
-	  }
-	catch (PropertyVetoException e)
-	  {
-	    // Do nothing if they don't want to be unselected.
-	  }
+        try
+          {
+            setSelected(false);
+          }
+        catch (PropertyVetoException e)
+          {
+            // Do nothing if they don't want to be unselected.
+          }
+      }
+    if (! isClosed)
+      {
+        firePropertyChange(IS_CLOSED_PROPERTY, Boolean.FALSE, Boolean.TRUE);
+        isClosed = true;
       }
-    isClosed = true;
     fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_CLOSED);
-    removeNotify();
   }
 
   /**
    * This method is used for closing this JInternalFrame. It fires an
    * INTERNAL_FRAME_CLOSING event and then performs the action specified by
    * the default close operation.
    */
   public void doDefaultCloseAction()
   {
     fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_CLOSING);
     switch (getDefaultCloseOperation())
       {
       case HIDE_ON_CLOSE:
 	    setVisible(false);
 	    break;
       case DISPOSE_ON_CLOSE:
 	    dispose();
 	    break;
       }
   }
@@ -782,42 +780,40 @@
    *     [EMAIL PROTECTED] WindowConstants#DO_NOTHING_ON_CLOSE}, 
    *     [EMAIL PROTECTED] WindowConstants#HIDE_ON_CLOSE}, or 
    *     [EMAIL PROTECTED] WindowConstants#DISPOSE_ON_CLOSE}).
    * 
    * @see #setDefaultCloseOperation(int)
    * @see #doDefaultCloseAction()
    */
   public int getDefaultCloseOperation()
   {
     return defaultCloseOperation;
   }
 
   /**
    * Returns the <code>JDesktopIcon</code> that represents this 
    * <code>JInternalFrame</code> while it is iconified.
    *
    * @return The desktop icon component.
    */
   public JDesktopIcon getDesktopIcon()
   {
-    if (desktopIcon == null)
-      desktopIcon = new JDesktopIcon(this);
     return desktopIcon;
   }
 
   /**
    * This method searches this JInternalFrame ancestors for an instance of
    * JDesktopPane. If one is found, it is returned. If none is found, then it
    * will search the JDesktopIcon for a JDesktopPane.
    *
    * @return The JDesktopPane that this JInternalFrame belongs to.
    */
   public JDesktopPane getDesktopPane()
   {
     JDesktopPane value = (JDesktopPane) SwingUtilities.getAncestorOfClass(JDesktopPane.class,
                                                                           this);
     if (value == null && desktopIcon != null)
       value = desktopIcon.getDesktopPane();
     return value;
   }
 
   /**
@@ -887,52 +883,41 @@
     return (InternalFrameListener[]) listenerList.getListeners(InternalFrameListener.class);
   }
 
   /**
    * This method returns the JMenuBar for this JInternalFrame.
    *
    * @return The JMenuBar for this JInternalFrame.
    */
   public JMenuBar getJMenuBar()
   {
     return getRootPane().getJMenuBar();
   }
 
   /**
    * This method returns the layer that this JInternalFrame resides in.
    *
    * @return The layer that this JInternalFrame resides in.
    */
   public int getLayer()
   {
-    JDesktopPane pane = getDesktopPane();
-    if (pane != null)
-      // The cast here forces the call to the instance method getLayer()
-      // instead of the static method (this would lead to infinite
-      // recursion).
-      return pane.getLayer((Component) this);
-    
-    Integer layer = (Integer) getClientProperty(JLayeredPane.LAYER_PROPERTY);
-    if (layer != null)
-      return layer.intValue();
-    
-    return JLayeredPane.DEFAULT_LAYER.intValue();
+    return JLayeredPane.getLayer(this);
   }
 
   /**
    * This method returns the LayeredPane for this JInternalFrame.
    *
    * @return The LayeredPane for this JInternalFrame.
    */
   public JLayeredPane getLayeredPane()
   {
     return getRootPane().getLayeredPane();
   }
 
   /**
    * This method is deprecated. This method returns the JMenuBar for this
    * JInternalFrame.
    *
    * @return The JMenuBar for this JInternalFrame.
    *
    * @deprecated 1.0.3
    */
@@ -953,41 +938,41 @@
    */
   public Component getMostRecentFocusOwner()
   {
     if (isSelected())
       return getFocusOwner();
     else
       return defaultFocus;
   }
 
   /**
    * This method returns the bounds of the JInternalFrame if it is not
    * maximized. If it is maximized, it returns the bounds of the
    * JInternalFrame before it was maximized (the bounds that it will be
    * restored to).
    *
    * @return A Rectangle that contains this JInternalFrame's normal bounds (or
    *         just its bounds if it is not maximized).
    */
   public Rectangle getNormalBounds()
   {
-    if (! isMaximum() && ! maxTransition)
+    if (storedBounds == null)
       return getBounds();
     else
       return storedBounds;
   }
 
   /**
    * This method returns the Root Pane for this JInternalFrame.
    *
    * @return The Root Pane for this JInternalFrame.
    */
   public JRootPane getRootPane()
   {
     return rootPane;
   }
 
   /**
    * Returns the frame's title.
    *
    * @return The frame's title (can be <code>null</code>).
    * 
@@ -1018,54 +1003,42 @@
   {
     return "InternalFrameUI";
   }
 
   /**
    * This method returns null.
    *
    * @return null.
    */
   public final String getWarningString()
   {
     // as defined.
     return null;
   }
 
   /**
    * This method deselects this JInternalFrame and hides it.
    */
   public void hide()
   {
-    JDesktopPane pane = getDesktopPane();
-    if (pane != null)
-      pane.setSelectedFrame(null);
-    else
-      {
-	try
-	  {
-	    setSelected(false);
-	  }
-	catch (PropertyVetoException e)
-	  {
-	    // Do nothing.
-	  }
-      }
+    if (isIcon())
+      getDesktopIcon().hide();
     super.hide();
   }
 
   /**
    * This method returns whether this JInternalFrame is closable.
    *
    * @return Whether this JInternalFrame is closable.
    */
   public boolean isClosable()
   {
     return closable;
   }
 
   /**
    * This method returns whether this JInternalFrame has been closed.
    *
    * @return Whether this JInternalFrame is closed.
    */
   public boolean isClosed()
   {
@@ -1145,74 +1118,77 @@
   {
     return rootPaneCheckingEnabled;
   }
 
   /**
    * This method returns whether this JInternalFrame is selected.
    *
    * @return Whether this JInternalFrame is selected.
    */
   public boolean isSelected()
   {
     return isSelected;
   }
 
   /**
    * A helper method that moves this JInternalFrame to the back if the parent
    * is a JLayeredPane.
    */
   public void moveToBack()
   {
-    if (getParent() instanceof JLayeredPane)
-      ((JLayeredPane) getParent()).moveToBack(this);
+    Container p = getParent();
+    if (p instanceof JLayeredPane)
+      ((JLayeredPane) p).moveToBack(this);
   }
 
   /**
    * A helper method that moves this JInternalFrame to the front if the parent
    * is a JLayeredPane.
    */
   public void moveToFront()
   {
-    if (getParent() instanceof JLayeredPane)
-      ((JLayeredPane) getParent()).moveToFront(this);
+    Container p = getParent();
+    if (p != null && p instanceof JLayeredPane)
+      ((JLayeredPane) p).moveToFront(this);
   }
 
   /**
    * This method causes the children of this JInternalFrame to be laid out.
    * Before it begins, if this JInternalFrame is an icon, then it will be
    * deiconified. If it is maximized, then it will be restored. If either
    * operation fails, then this method will return.
    */
   public void pack()
   {
     try
       {
 	if (isIcon())
 	  setIcon(false);
 	else if (isMaximum())
 	  setMaximum(false);
       }
     catch (PropertyVetoException e)
       {
 	// Do nothing if they don't want to be restored first.
       }
     setSize(getPreferredSize());
+    validate();
   }
 
   /**
    * This method is overridden to allow for speedier painting while this
    * JInternalFramme is being dragged.
    *
    * @param g The Graphics object to paint with.
    */
   protected void paintComponent(Graphics g)
   {
     super.paintComponent(g);
   }
 
   /**
    * An implementation dependent string describing the current state of this 
    * <code>JInternalFrame</code> instance.
    *
    * @return A string describing the current state of this 
    *     <code>JInternalFrame</code> instance.
    */
@@ -1294,41 +1270,40 @@
    * listeners to cancel the close. If no listener vetoes the change, the
    * closed property is set to true and the JInternalFrame is hidden and
    * unselected. The method will finish by firing an INTERNAL_FRAME_CLOSED
    * event.
    *
    * @param b Whether the JInternalFrame will be closed.
    *
    * @throws PropertyVetoException If a VetoableChangeListener vetoes the change.
    */
   public void setClosed(boolean b) throws PropertyVetoException
   {
     if (b && ! isClosed())
       {
         fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_CLOSING);
         fireVetoableChange(IS_CLOSED_PROPERTY, false, true);
 
         isClosed = b;
         dispose();
 
         firePropertyChange(IS_CLOSED_PROPERTY, false, true);
-        fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_CLOSED);
       }
   }
 
   /**
    * This method sets the Container to be used as a Content Pane for this
    * JInternalFrame.
    *
    * @param c The Container to use as a Content Pane.
    */
   public void setContentPane(Container c)
   {
     if (c != getContentPane())
       {
 	Container old = getContentPane();
 	getRootPane().setContentPane(c);
 	firePropertyChange(CONTENT_PANE_PROPERTY, old, c);
       }
   }
 
   /**
@@ -1451,80 +1426,91 @@
    * that the JInternalFrame can be turned into an icon if minimized).
    *
    * @param b Whether the JInternalFrame can be iconified.
    */
   public void setIconifiable(boolean b)
   {
     if (iconable != b)
       {
         iconable = b;
         firePropertyChange("iconable", ! iconable, iconable);
       }
   }
 
   /**
    * This method sets the JMenuBar to be used with this JInternalFrame.
    *
    * @param b The JMenuBar to be used with this JInternalFrame.
    */
   public void setJMenuBar(JMenuBar b)
   {
+    JMenuBar old = getJMenuBar();
     getRootPane().setJMenuBar(b);
+    firePropertyChange(MENU_BAR_PROPERTY, old, b);
   }
 
   /**
    * A helper method that set the layer that this JInternalFrame resides in.
    * Using this version of the method means that the user should not set it
    * to values that are already defined in JLayeredPane. If predefined values
    * are to be used, the user should use the setLayer(Integer) version.
    *
    * @param layer The layer to place this JInternalFrame in.
    */
   public void setLayer(int layer)
   {
     setLayer(new Integer(layer));
   }
 
   /**
    * A helper method that sets the layer that this JInternalFrame resides in.
    * Calling this version of the method should use layer values that are
    * already defined in JLayeredPane.
    *
    * @param layer The layer to place this JInternalFrame in.
    */
   public void setLayer(Integer layer)
   {
-    JDesktopPane p = getDesktopPane();
-    if (p != null)
+    Container p = getParent();
+    if (p instanceof JLayeredPane)
       {
-	int pos = p.getPosition(this);
-	p.setLayer(this, layer.intValue(), pos);
+        JLayeredPane lp = (JLayeredPane) p;
+        lp.setLayer(this, layer.intValue(), lp.getPosition(this));
+      }
+    else
+      {
+        JLayeredPane.putLayer(this, layer.intValue());
+        if (p != null)
+          p.repaint(getX(), getY(), getWidth(), getHeight());
       }
   }
 
   /**
    * This method sets the JLayeredPane to use with this JInternalFrame.
    *
    * @param layered The JLayeredPane to use as a layeredPane.
    */
   public void setLayeredPane(JLayeredPane layered)
   {
+    if (layered == null)
+      throw new IllegalComponentStateException("LayeredPane must not be null");
+
     if (layered != getLayeredPane())
       {
 	JLayeredPane old = getLayeredPane();
 	getRootPane().setLayeredPane(layered);
 	firePropertyChange(LAYERED_PANE_PROPERTY, old, layered);
       }
   }
 
   /**
    * This method sets whether the JInternalFrame can be maximized.
    *
    * @param b Whether this JInternalFrame can be maximized.
    */
   public void setMaximizable(boolean b)
   {
     if (maximizable != b)
       {
         maximizable = b;
         firePropertyChange("maximizable", ! maximizable, maximizable);
       }
@@ -1544,207 +1530,216 @@
   public void setLayout(LayoutManager manager)
   {
     // Check if we're in initialization stage.  If so, call super.setLayout
     // otherwise, valid calls go to the content pane.
     if (isRootPaneCheckingEnabled())
       getContentPane().setLayout(manager);
     else
       super.setLayout(manager);
   }
 
   /**
    * This method sets the JInternalFrame to maximized (if the given argument
    * is true) or restores the JInternalFrame to its normal bounds otherwise.
    *
    * @param b Whether this JInteralFrame will be maximized or restored.
    *
    * @throws PropertyVetoException If a VetoableChangeListener vetoes the change.
    */
   public void setMaximum(boolean b) throws PropertyVetoException
   {
-    if (b != isMaximum())
+    if (b != isMaximum)
       {
-	fireVetoableChange(IS_MAXIMUM_PROPERTY, b, isMaximum);
+	fireVetoableChange(IS_MAXIMUM_PROPERTY, isMaximum, b);
 	isMaximum = b;
-	if (b)
-	  setNormalBounds(getBounds());
-	maxTransition = ! b;
 	firePropertyChange(IS_MAXIMUM_PROPERTY, ! isMaximum, isMaximum);
-	maxTransition = false;
       }
   }
 
   /**
    * This method is deprecated. This method sets the JMenuBar used with this
    * JInternalFrame.
    *
    * @param m The JMenuBar to use with this JInternalFrame.
    *
    * @deprecated 1.0.3
    */
   public void setMenuBar(JMenuBar m)
   {
     setJMenuBar(m);
   }
 
   /**
    * This method sets the bounds that this JInternalFrame will be restored to.
    *
    * @param r The bounds that this JInternalFrame will be restored to.
    */
   public void setNormalBounds(Rectangle r)
   {
-    storedBounds.setBounds(r.x, r.y, r.width, r.height);
+    storedBounds = r;
   }
 
   /**
    * This method sets whether the JInternalFrame can be resized by a user
    * action (like dragging at the frame borders).
    *
    * @param b Whether this JInternalFramer can be resized.
    */
   public void setResizable(boolean b)
   {
     if (b != resizable)
       {
         resizable = b;
         firePropertyChange("resizable", ! resizable, resizable);
       }
   }
 
   /**
    * This method sets the Root Pane for this JInternalFrame.
    *
    * @param root The Root Pane for this JInternalFrame.
    */
   protected void setRootPane(JRootPane root)
   {
     if (rootPane != null)
       remove(rootPane);
 
+    JRootPane old = rootPane;
     rootPane = root;
-    add(root);
+
+    if (rootPane != null)
+      {
+        boolean checkingEnabled = isRootPaneCheckingEnabled();
+        try
+          {
+            setRootPaneCheckingEnabled(false);
+            add(rootPane, BorderLayout.CENTER);
+          }
+        finally
+          {
+            setRootPaneCheckingEnabled(checkingEnabled);
+          }
+      }
+    firePropertyChange(ROOT_PANE_PROPERTY, old, rootPane);
   }
 
   /**
    * This method sets whether root pane checking is enabled. If root pane
    * checking is enabled, then calls to addImpl and setLayout will throw
    * exceptions.
    *
    * @param enabled Whether root pane checking is enabled.
    */
   protected void setRootPaneCheckingEnabled(boolean enabled)
   {
     rootPaneCheckingEnabled = enabled;
   }
 
   /**
    * This method sets whether this JInternalFrame is the selected frame in the
    * JDesktopPane (or other container). When selected, a JInternalFrame will
    * have focus and paint its TitlePane differently (usually a different
    * colour). If this method selects the frame, this JInternalFrame will fire
    * an INTERNAL_FRAME_ACTIVATED event. If it deselects this frame, it will
    * fire an INTERNAL_FRAME_DEACTIVATED event.
    *
    * @param selected Whether this JInternalFrame will become selected or
    *        deselected.
    *
    * @throws PropertyVetoException If a VetoableChangeListener vetoes the change.
    */
   public void setSelected(boolean selected) throws PropertyVetoException
   {
-    if (selected != isSelected())
+    if (selected != isSelected
+        && (! selected || (isIcon ? desktopIcon.isShowing() : isShowing())))
       {
-	fireVetoableChange(IS_SELECTED_PROPERTY, selected, isSelected);
-
-	if (! selected)
-	  defaultFocus = getMostRecentFocusOwner();
+        fireVetoableChange(IS_SELECTED_PROPERTY, isSelected, selected);
 
-	isSelected = selected;
+        if (! selected)
+          defaultFocus = getMostRecentFocusOwner();
 
-	if (selected)
-	  restoreSubcomponentFocus();
+        isSelected = selected;
+        firePropertyChange(IS_SELECTED_PROPERTY, ! isSelected, isSelected);
 
-    if (isShowing())
-      repaint();
+        if (isSelected)
+          fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_ACTIVATED);
+        else
+          fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_DEACTIVATED);
 
-	firePropertyChange(IS_SELECTED_PROPERTY, ! isSelected, isSelected);
+        if (selected)
+          restoreSubcomponentFocus();
 
-	if (isSelected)
-	  fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_ACTIVATED);
-	else
-	  fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_DEACTIVATED);
+        repaint();
       }
   }
 
   /**
    * Sets the title for the <code>JInternalFrame</code> and sends a 
    * [EMAIL PROTECTED] PropertyChangeEvent} (with the property name 
    * [EMAIL PROTECTED] #TITLE_PROPERTY}) to all registered listeners.
    *
    * @param title  the new title (<code>null</code> permitted).
    * 
    * @see #getTitle()
    */
   public void setTitle(String title)
   {
-    if (title == null && this.title == null)
-      return;
-    if (title == null || this.title == null || ! this.title.equals(title))
-      {
-        String old = this.title;
-        this.title = title;
-        firePropertyChange(TITLE_PROPERTY, old, this.title);
-      }
+    String old = this.title;
+    this.title = title;
+    firePropertyChange(TITLE_PROPERTY, old, this.title);
   }
 
   /**
    * This method displays the JInternalFrame. If it is not visible, this
    * method will bring this JInternalFrame to the front, make it visible and
    * select it. If this is the first time this JInternalFrame is made
    * visible, an INTERNAL_FRAME_OPENED event will be fired.
    */
   public void show()
   {
     if (! isVisible())
       {
+        if (isFirstTimeVisible)
+          {
+            isFirstTimeVisible = false;
+            fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_OPENED);
+          }
+
+        getDesktopIcon().setVisible(true);
+
+        toFront();
         super.show();
 
-        JDesktopPane pane = getDesktopPane();
-        if (pane != null)
-          pane.setSelectedFrame(this);
-        else
+        if (isIcon())
+          return;
+
+        if (! isSelected())
           {
             try
               {
                 setSelected(true);
               }
             catch (PropertyVetoException e)
               {
                 // Do nothing. if they don't want to be selected.
               }
           }
-        if (isFirstTimeVisible)
-          {
-            isFirstTimeVisible = false;
-            fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_OPENED);
-          }
       }
   }
 
   /**
    * This method is used to set the UI responsible for the JInternalFrame.
    *
    * @param ui The UI responsible for the JInternalFrame.
    */
   public void setUI(InternalFrameUI ui)
   {
     // We must temporarily go into init mode so that the UI can directly
     // manipulate the JInternalFrame.
     boolean old = isRootPaneCheckingEnabled();
     setRootPaneCheckingEnabled(false);
     super.setUI(ui);
     setRootPaneCheckingEnabled(old);
   }
 
   /**
    * This method causes the JInternalFrame to be brough to back in the

Attachment: signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil

Reply via email to