How should i handle click events of a JButton array
i have frame containing 100 JButtons .I need to find out which one was pressed by the user
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import javax.swing.*;
public class Screen1 implements ActionListener , WindowListener
{
int i;
JFrame scrfrm1;
JLabel lblscr;
JButton seats[] = new JButton[100];
int left,top;
Screen1()
{
scrfrm1 = new JFrame("Screen1");
for(i=0;i<100;i++)
seats[i] = new JButton(String.valueOf(i + 1));
//line one of buttons
//seat1.setBounds
//setting cutomised button layout
scrfrm1.addWindowListener(this);
scrfrm1.setLayout(null);
scrfrm1.setBounds(100,0,1200,740);
scrfrm1.setVisible(true);
scrfrm1.setResizable(true);
}
public void actionPerformed(ActionEvent ae)
{
for(i=0;i<100;i++)
{
if(ae.getSource()==seats[i])
{
}
}
}
public void windowOpened(WindowEvent we){}
public void windowClosed(WindowEvent we){}
public void windowClosing(WindowEvent we)
{
/*String ObjButtons[] = {"Yes","No"};
int PromptResult = JOptionPane.showOptionDialog(null,"Are you sure you want to exit?","Multiplex Theatre Central",JOptionPane.DEFAULT_OPTION,JOptionPane.WARNING_MESSAGE,null,ObjButtons,ObjButtons[1]);*/
//if(PromptResult==0)
//{
System.exit(0);
//}
//else
//{
//MainPage mp=new MainPage();
//}
}
public void windowIconified(WindowEvent w){}
public void windowDeiconified(WindowEvent w){}
public void windowActivated(WindowEvent w){}
public void windowDeactivated(WindowEvent w){}
public static void main(String args[])
{
Screen1 scr1 = new Screen1();
}
}