Java ActionListeners regarding changing buttons when clicked
<pre><code>package tictactoe;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class TicTacToe extends JFrame implements ActionListener  {
    JPanel mainPanel=new JPanel();
    JButton[] buttons=new JButton[9];
public TicTacToe()
{
    super("Tic Tca Toe");
    setSize(400,400);
    setResizable(false);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setLookAndFeel();
    mainPanel.setLayout(new GridLayout(3,3,5,5));
       for(int i=0;i&lt;9;i++)
       {
           buttons[i]=new JButton();
           buttons[i].addActionListener(this);
           mainPanel.add(buttons[i]);
       }

        add(mainPanel);
        setVisible(true);
}
    private void setLookAndFeel()
    {
        try
        {
            UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
        }catch(Exception e)
        {

        }
    }

public void actionPerformed(ActionEvent event) 
{


}
public static void main(String[] args)
{
new TicTacToe();
}

}
</code></pre>

<p>The problem is i want to make it so that the buttons i made at the top when they get clicked the text inside the changes from blank to X to O to blank if you keep clicking so it cycles through those 3 states but i cannot figure it out any help?</p>