import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

public class trafikIsigi1SWF extends JFrame implements ActionListener
{
    isikKontroluThread1 yik;
    JButton light_switch;
    JTextField t1,t2;
    JLabel l0,l1,l2,l3,l4;
    trafikIsigi1SWP ti1;
    Container c;

    public trafikIsigi1SWF()
    {
        c=getContentPane();
        JPanel p1=new JPanel();
        p1.setLayout(new GridLayout(2,4));
        yik=new isikKontroluThread1(this);
        yik.start();
        ti1=new trafikIsigi1SWP(yik);
        light_switch = new JButton("Işığı değiştir");
        light_switch.setForeground(Color.black);
        light_switch.setBackground(Color.lightGray);
        t1=new JTextField(""+yik.getYesilZaman());
        t2=new JTextField(""+yik.getKirmiziZaman());
        l0=new JLabel("                            ");
        l1=new JLabel("yesil isik yanma zamani :   ");
        l2=new JLabel("saniye                      ");
        l3=new JLabel("kirmizi isik yanma zamani : ");
        l4=new JLabel("saniye                      ");
        p1.add(light_switch);
        p1.add(l1);
        p1.add(t1);
        p1.add(l2);
        p1.add(l0);
        p1.add(l3);
        p1.add(t2);
        p1.add(l4);
        light_switch.addActionListener(this);
        t1.addActionListener(this);
        t2.addActionListener(this);
        c.add(p1,BorderLayout.NORTH);
        c.add(ti1,BorderLayout.CENTER);
    }
public void actionPerformed(ActionEvent e)
{
  if(e.getSource()==light_switch)
  {
     repaint();
  }
  else if(e.getSource()==t1)
  {
     Double i1=new Double(t1.getText());
     yik.setYesilZaman(i1.doubleValue());
  }
  else if(e.getSource()==t2)
  {
     Double i1=new Double(t1.getText());
     yik.setKirmiziZaman(i1.doubleValue());
  }
}

public static void main(String[] args)
      {
      trafikIsigi1SWF pencere= new trafikIsigi1SWF();
      pencere.addWindowListener(new BasicWindowMonitor());
      pencere.setSize(300,600);
      pencere.setVisible(true);
      }

}
