I want to make a drawing (A rectangle which is colored according RGB values that are scanned real-time), and add this drawing to a JPanel. This JPanel has to be added to the layout of the main frame. If I make a class which extends JPanel, and draw the rectangle in the paintComponent(Graphics g) method, the drawing isn't displayed.