I have been trying to convert an applet from awt to swing. My applet contained an inner class which extended the Canvas class, and this class overrided the paint method to draw a square grid using the fillRect(x,y,width, height) method. So to convert it to swing, instead of making the class extend Canvas, I decided to make it extend JPanel, and I changed the paint(Graphics g) method to paintComponent(Graphics g). The problem is that now the grid is only 1 line high. The width is fine, but the height is a problem. I havent made a mistake with the parameters entered in the fillRect method, and when I change the class back to a subclass of canvas, the grid appears to be fine again.