// method for drawing on a JPanel public void paintComponent(Graphics g) { super.paintComponent(g); // call constructor of JPanel g.drawString("This is my custom Panel!",10,20); // draw text g.setColor(Color.red); // set the drawing color to red g.fillRect(20,40,50,100); // draw a filled red rectangle }