What code shall I use to add shadow effects to a panel in Java swing, I know the same is available in javafx but can we do the same in swing?
Swing does not provide built-in capabilities for these.
You can drop shadow either by adding border or draw manually. Here are some examples for dropping shadow from JPanel
Animation is more complex, one approach is to use timer and change properties or draw on appropriate ticks, another is to incorporate some library like Timing Framework.
As a side note, you are asking two different questions in one and probably you need to do some research by yourself before posting and provide the results in the question.