import java.lang.Integer;
import java.awt.*;
import java.awt.event.*;
import java.awt.font.*;
import java.awt.geom.*;
import java.awt.image.*;
import javax.swing.*;
import java.util.Locale;
import java.text.*;
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.table.*;

public class girdiP extends JPanel implements ActionListener
{
  JPanel p1,p2,p3,p;
  JLabel l1[];           // Label prompt unit
  JLabel l2[];           // Label prompt unit
  JTextField t1[];
  double a[];
  JLabel heading;
  //JButton jb;
  int n;
  public girdiP(String s1[],String s2[],double t[],String hh)
  { n=t.length;
    l1=new JLabel[n];
    l2=new JLabel[n];
    t1=new JTextField[n];
    a=new double[n];
    heading=new JLabel(hh);
    //jb=new JButton("hesapla");

    p1=new JPanel();
    p2=new JPanel();
    p3=new JPanel();
       p=new JPanel()
       {
        public Dimension getPrefferedSize()
        {
            Dimension size=super.getPreferredSize();
            size.width=200;
            size.height=100;
            return size;
        }
        };   
    p2.setLayout(new FlowLayout(FlowLayout.CENTER));
    p1.add(heading);
    p.setLayout(new BorderLayout(5,5));
    p2.setLayout(new GridLayout(n,3,5,5));
    for(int i=0;i<n;i++)
    {
	 l1[i]=new JLabel(s1[i]);
	 l2[i]=new JLabel(s2[i]);
	 t1[i]=new JTextField(t[i]+"                           ");	 
	 t1[i].addActionListener(this);
	 p2.add(l1[i]);
	 p2.add(t1[i]);
	 p2.add(l2[i]);
	 a[i]=t[i];
	}
	p.add(p1,BorderLayout.NORTH);
	p.add(p2,BorderLayout.CENTER);
	add(p);
  }
  
  public void actionPerformed( ActionEvent e)
  {
  int i=0;
  for(i=0;i<n;i++)
  {	if(e.getSource()==t1[i])
    { a[i]=Double.parseDouble(t1[i].getText());break;}
  }
  System.out.println(" a["+i+"] = "+a[i]);
  repaint();
  }
    
  public double[] readText()
  {return a;}
  
    
 }

