/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package a01;

import java.awt.TextField;
import java.awt.event.ActionListener;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.Color;
import java.awt.event.ActionEvent;
import javax.swing.AbstractButton;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.UIManager;
import javax.swing.JScrollPane;
import javax.swing.JTable;

public class A01 extends javax.swing.JFrame
{
    public static void createGUI() 
    {
        JPanel panel = new JPanel();
        panel.setLayout(null);
        
        JFrame.setDefaultLookAndFeelDecorated(true);
        final JFrame frame = new JFrame("Test frame");
        frame.getContentPane().add(panel);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setPreferredSize(new Dimension(1000, 1000));          
        frame.pack();
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
        
        int N = 7;
        int Wii = 60;
        int Hii = 30;
        JTextField tbl[] = new JTextField[N*N];
        for(int i=0;i<N;i++)
        {
            for(int j=0;j<N;j++)
            {
                int k=i*N+j;
                tbl[k]=new JTextField(/*i+"."+j*/);
                tbl[k].setBounds(150+(i*Wii), 150+(j*Hii),Wii,Hii);
                if(i==j)
                {
                    tbl[k].setBackground(Color.gray);
                    tbl[k].setText("");
                }
                tbl[k].addActionListener(new ActionListener()
                { // Анонимный класс
                    @Override // Значение k - отдельно для каждого
                    public void actionPerformed(ActionEvent e) {
                        int vv=Integer.parseInt(tbl[k].getText());
                        tbl[k].setText(""+(++vv));
                    }
                });
                panel.add(tbl[k]);
            }
        }
    }
    
    public static void main(String[] args)
    {
        createGUI();
    }
}



/*Крипи-тред!*/
/*BUFFOON!!*/

    /*public static void main(String[] args) 
    {
        JFrame frame = new JFrame("Test frame");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        JTable table = new JTable();
        table.setPreferredSize(new Dimension(10, 10));
        JScrollPane scrollPane = new JScrollPane(table);
        
        
        final JButton centerButton = new JButton("Center");
        
        centerButton.setVerticalTextPosition(AbstractButton.BOTTOM);
          centerButton.setHorizontalTextPosition(AbstractButton.CENTER);
          centerButton.setEnabled(false);
          
          centerButton.setPreferredSize(new Dimension(10, 10));
        
        
         frame.add(centerButton);
        
        
        frame.getContentPane().add(scrollPane);
        frame.setPreferredSize(new Dimension(450, 200));
        frame.pack();
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    }*/




/*JButton button1 = new JButton("Button 1");
        button1.setBounds(5, 5, 85, 30);
        panel.add(button1);
        
        JButton button2 = new JButton("Button 2");
        button2.setBounds(95, 40, 85, 30);
        panel.add(button2);
        
        JButton button3 = new JButton("Button 3");
        button3.setBounds(185, 75, 85, 30);
        panel.add(button3);
        
        JTextField g75 = new JTextField("Buffon");
        g75.setBounds(10, 10,10,10);
        panel.add(g75);
        
        
        JButton centerButton = new JButton("Ю-25");
        centerButton.setBounds(30, 30,20,20);
        
        JTextField g76 = new JTextField("3");
        g76.setBounds(100, 100,20,20);
        
        panel.add(centerButton);
        panel.add(g76);*/