The issue is due to Java 7's tweaking on javax.swing.plaf.basic.BasicInternalFrameUI implementation.
Java 1.6 Code
public void propertyChange(PropertyChangeEvent evt) {
if ((frame.getParent() != null) && !componentListenerAdded) { f.getParent().addComponentListener(componentListener); componentListenerAdded = true; } else if ((newValue == null) && componentListenerAdded) { if (f.getParent() != null) { f.getParent() .removeComponentListener(componentListener); } componentListenerAdded = false; }
Java 1.7 Code
public void propertyChange(PropertyChangeEvent evt) {
if ((frame.getParent() != null) && !componentListenerAdded) { f.getParent().addComponentListener(componentListener); componentListenerAdded = true; }
NOTE: The else if condition was removed. This is the culprit.
I suggest you 2 options:
Option one
JInternalFrame selectedFrame = desktopPane.getSelectedFrame(); desktopPane.remove(selectedFrame); desktopPane.repaint(); secondFrame.updateUI(); // The magic part, less expensive execution. secondFrame.addInternalFrame(selectedFrame);
Option two
You may need to recompile javax.swing.plaf.basic.BasicInternalFrameUI.java with above "else if" condition and add to your rt.jar library's javax.swing.plaf.basic location.
I have attached the recompiled files for Java 1.7.0_25 at http://www.datafilehost.com/d/dfb7238c
Hope this helps!!!
Regards, Nilindra