posted 12 years ago
The reason JDialog has a dispose() method is that JDialog has a native peer, that is, some windowing component attached to the native operating system. These native peers exist outside the JVM so the garbage collector will not free them. It is up to us to do it manually. JPanel has no native peer so it is not necessary to manually dispose of its resources. Set all your references to it to null and it will get cleaned up automatically.