I have a JScrollPane and on top of it I have a JPanel named \'panel1\'. I want some rectangles to be drawn on this JPanel.
I have a class named DrawRectPanel which e
instead of adding
contentPane.add(new DrawRectPanel());
you should do
contentPane.add(panel1);
Because you already have new DrawRectPanel in panel1. But in your code you are adding another instance of DrawRectPanel in contentPane. And never added panel1 in none of your container.
DrawRectPanel
contentPane
panel1
container