Drawing rectangles on a JPanel
问题 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 extends JPanel and does all the drawing stuff. The problem is that, I tried to draw the rectangles on panel1 by writing the following code : panel1.add(new DrawRectPanel()); but nothing appeared on panel1 then I tried, just as a test to the class DrawRectPanel : JFrame frame = new JFrame(); frame.setSize(1000, 500); Container