paintComponent() slowing down after adding a image to the background
<p>I'm creating an game in Java in a JPanel that takes user input to change player coordinates. In the JPanel I create, I say </p>

<pre><code>        Thread gameThread = new Thread()
    {
        public void run()
        {
            while(true){
                frameCount++;
                repaint();
                code();
                try{
                    Thread.sleep((long)(1000/Main.UPDATE_RATE));
                } catch(InterruptedException e){
                    e.printStackTrace();
                }


            }
        }
    };
</code></pre>

<p>Where repaint() is where I update the JPanel and code() is where I process the information.</p>

<p>Right now, I have some images and rectangles that are being placed on the JPanel, and the repaint() and code() methods are running at the same speed. However, after I add </p>

<pre><code>    for(int y = 0; y &lt; screenHeight; y += backgroundHeight){
        for(int x = 0 - getBackgroundDisplacement() - backgroundWidth; x &lt; screenWidth; x += backgroundWidth){
            g2d.drawImage(background, x, y, null);

        }
    }
</code></pre>

<p>the repaint() runs about 2/3 the speed of the code().</p>

<p>Is there any reason why the paint would slow down so much for adding a few images (around 4) to the background?</p>