dragging line is going behind rectangle
===

I have three class CanvasPanel,Drawline,DrawRectangle. 
CanvasPanel:- This is for handling all mouse event listener.
Drawline :this is for drawing line on CanvasPanel.
DrawRectangle: this is for drawing rectangle on CanvasPanel.
All three class are extending JPanel class.

drag and drop of all component is going fine. but the problem is when I drag the line over the rectangle then line has been gone behind the rectangle.can you give me the solution or give me some example. so i can understand how this is happening.

thanks