grid layout panels in a jframe
<p>How would i be able to use gridlayout and panels to create a frame that resembles a checkered board pattern? it would seem that i can't create two panels with two diferent colors within the one for-loop.</p>

<pre><code>import javax.swing.*;
import java.awt.*;

@SuppressWarnings("serial")
public class test extends JFrame {
    public test() {

        this.setSize(400, 400);


        JPanel content = new JPanel(new GridLayout(4,4));
        for(int i = 0; i &lt; 8; i++) {
            JPanel panel = new JPanel();
            panel.setBackground(Color.RED);
            content.add(panel);

            JPanel panel2 = new JPanel();
            panel.setBackground(Color.BLUE);
            content.add(panel2);
        }

    //  for(int i = 0; i &lt; 8; i++) {
    //      JPanel panel = new JPanel();
    //      panel.setBackground(Color.BLUE);
    //      content.add(panel);
    //  }

        this.add(content);
    }

    public static void main(String[] args) {
        test app = new test();
        app.setVisible(true);
        app.setResizable(false);
        app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
}
</code></pre>
