<p>Wnen I use external resources such as files or DB connection I need to close them before I let them go.</p>

<p>Do I need to do the same thing with Swing components ? If yes then how ?</p>

Objects are automatically garbage collected if there are no references to them. You do not have to treat Swing components the same way that you do external resources. However, if you have a component that you are not going to need later you can set any references to that component to null.
```
```
JPanel p = new JPanel();
p = null;
```
```
Setting p to null does not delete the object but it removes any references to the object so the next time the garbage collector passes it gets picked up.
You will have to be careful though that other reference to the component do not exist.