Winning Loop Connect 4 I am writing a fully functional single player Connect 4 game. I am working on the second player and the while loop that tells the player who won. 

GUI

package lab7; 



import java.awt.GridLayout;
import java.util.ArrayList;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class GUIClass implements Runnable {

    @Override
    public void run() {

        JFrame f = new JFrame("CSE 115 Connect 4");
        f.setVisible(true);
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        GridLayout myGrid = new GridLayout(7, 6);
        JPanel panel;
        panel = new JPanel();
        panel.setLayout(myGrid);
        f.setLayout(myGrid);

        f.pack();

        ArrayList&lt;JButton&gt; col_button = new ArrayList&lt;JButton&gt;();
        for (Integer i = 1; i &lt;= 7; i++)
        {
            JButton b = new JButton("Col " + i.toString());
            col_button.add(b);
            f.add(b);
        }

        ArrayList&lt;ArrayList&lt;JLabel&gt;&gt; col_list = new ArrayList&lt;ArrayList&lt;JLabel&gt;&gt;();
        for (int i = 0; i &lt; 7; i++)
        {
            col_list.add(new ArrayList&lt;JLabel&gt;());
        }

        for (int i = 0; i &lt; 42; i++)
        {


            JLabel label = new JLabel(new ImageIcon("images/blank.png"));
            //System.out.println(label.getIcon().toString())
            col_list.get(i % 7).add(label);
            f.add(label);
        }
        GameClass gc = new GameClass(col_list);

        for (int i = 0; i &lt; 7; i++)
        {
            col_button.get(i).addActionListener(new ColButton(col_list.get(i)));
        }

        f.pack();

    }

    ImageIcon whiteCircle = new ImageIcon("blank.png");
}


that contains all of the graphical interface behind my code, as you might have guessed I used Java and Eclipse. 

This is my game class where my second player is going to be, and I also assume my winning loop will be here. 

import java.awt.event.ActionListener;
import java.util.ArrayList;

import javax.swing.JLabel;

public class GameClass{

    public GameClass(ArrayList&lt;ArrayList&lt;JLabel&gt;&gt; col_list)
    {

    }
}


finally this is my column class which contains the 1st player and all the buttons. 

package lab7;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;

import javax.swing.ImageIcon;
import javax.swing.JLabel;

public class ColButton implements ActionListener {

    private ArrayList&lt;JLabel&gt; _column;
    private GameClass _game;

    public ColButton(ArrayList&lt;JLabel&gt; c)
    {
        _column = c;
    }
    @Override
    public void actionPerformed(ActionEvent e) {
        // TODO Auto-generated method stub
        for (int i = _column.size() - 1; i &gt;= 0; i--)
        {
            JLabel l = _column.get(i);
            if(l.getIcon().toString().equals("images/blank.png"))
            {
                l.setIcon(new ImageIcon("images/red.png"));
                break;
            }
        }
    }

}


What do you think?  Any suggestions on how to get get going for the second part? I am working on the 2nd player but I have run into some setbacks.
Typically, a Swing application would be written using a Model-View-Controller pattern to split the responsibilities:


The Model would be a data structure to represent the game state.  It could, for example, consist of an ConnectFourBoard class that holds a two-dimensional array of chips in the board.
The View would be the Swing UI code
The Controller acts as the glue between the Model and View.  It handles actions triggered by the View, and notifies the View when the Model has changed.


Here, I see View and Controller code, commingled.  However, I don't see any Model code.  In fact, in ColButton.actionPerformed(), it appears that the lack of a Model is causing you some difficulty: you're resorting to determining the model state by parsing the icon name out of the view.

Without a Model, you are no doubt going to have a difficult time examining the model state to determine the winner.