jdk/src/share/classes/javax/swing/JFileChooser.java
changeset 3346 1c65be97eaa2
parent 1301 15e81207e1f2
child 3982 b8872825ad04
--- a/jdk/src/share/classes/javax/swing/JFileChooser.java	Wed Jul 22 12:21:31 2009 +0400
+++ b/jdk/src/share/classes/javax/swing/JFileChooser.java	Thu Jul 23 17:56:53 2009 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright 1997-2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -739,6 +739,11 @@
 
         dialog.show();
         firePropertyChange("JFileChooserDialogIsClosingProperty", dialog, null);
+
+        // Remove all components from dialog. The MetalFileChooserUI.installUI() method (and other LAFs)
+        // registers AWT listener for dialogs and produces memory leaks. It happens when
+        // installUI invoked after the showDialog method.
+        dialog.getContentPane().removeAll();
         dialog.dispose();
         dialog = null;
         return returnValue;