There are a lot of code samples on the forum that use the paintComponent method. Try doing a Search here.
Type: Posts; User: Norm
There are a lot of code samples on the forum that use the paintComponent method. Try doing a Search here.
If you mean to display the image with a rectangle on it,
In a paintComponent method, draw the image first and then draw the rectangle