package midterm2;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class midterm2task1 {
public static void main(String[] args) {
JFrame frame = new JFrame();
frame.setSize(300, 200); //
GridLayout grid = new GridLayout(3, 4);
frame.setLayout(grid);
JButton b1 = new JButton("0");
int a = Integer.parseInt(b1.getLabel());
JButton[] array1 = new JButton[12];
for(int i = 0; i<12; i++) {
array1[i] = new JButton();
a++;
array1[i].setLabel(""+a);
frame.add(array1[i]);
}
int b = Integer.parseInt(b1.getLabel());
for(int i=0;i<12;i++) {
array1[i].addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
for (int j = 0; j < 12; j++) {
array1[j].setLabel("1");
frame.add(array1[j]);
}
}
});
}
frame.setVisible(true);
}
}