package ru.mai.dep806.table;

import java.awt.Dimension;

import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;

/**
 * Created by Vol4ica on 15.06.2015.
 */
 public class Table1 extends JTable
{

    int a, b;

    public Table1(int a, int b) {
        this.a = a;
        this.b = b;

        getColumnNames(a);

    }

    public int getA() {
        return a;
    }

    public void setA(int a) {
        this.a = a;
    }

    public int getB() {
        return b;
    }

    public void setB(int b) {
        this.b = b;
    }

  public static int[][] getMatrix(int a, int b) {
        if (a <= 0 | a >= 50 | b <= 0 | b >= 50) {
            return null;
        } else {
            int[][] matrixA;
            matrixA = new int[a + 1][b + 1];
            for (int l = 0; l <= a; l++) {
                for (int m = 0; m <= b; m++) {
                    matrixA[l][m] = l * m;
                }
            }

            for (int j = 1; j <= b; j++) {
                for (int i = 1; i <= a; i++) {

                }

            }
            return matrixA;
        }
    }

    String[] columnNames;

    public String[] getColumnNames(int a) {
        String[] a1 = new String[a + 1];
        a1[0] = " ";
        for (int i = 1; i <= a; i++) {
            String str = Integer.toString(i);
            a1[i] = Integer.toString(i);
        }
        return columnNames = a1;
    }


    public void setColumnNames(String[] columnNames) {
        this.columnNames = columnNames;
    }

    String[][] data;

    public String[][] getData(int a, int b) {
        String[][] a1 = new String[a + 1][b];
        int[][] a2 = getMatrix(a, b);
        for (int i = 1; i <= b; i++) {
            String str = Integer.toString(i);
            a1[i][0] = Integer.toString(i);
        }
        for (int i = 1; i <= b; i++) {
            for (int j = 1; i <= a + 1; i++) {
                a1[i][j] = Integer.toString(a2[i - 1][j - 1]);
            }
        }
        return data = a1;
    }

    public void setData(String[][] data) {
        this.data = data;
    }

    JTable table = new JTable(data, columnNames);

    JScrollPane scrollPane = new JScrollPane(table);



}

