import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;

public class vw4 extends Applet{
    Graphics g;
    static int DOUBLENUM = 2;                  //GUIの変数の数をいれる。
    Gui_double []gui= new Gui_double[DOUBLENUM];
    
    public void init(){
        Button bt;
       	g=getGraphics();
        //ここにラベルと初期値をいれる。使う数だけ初期化する。
	gui[0]=new Gui_double("freq. 10<f1<50","15",5);
	gui[1]=new Gui_double("freq. 10<f2<50","17",5);
        //
        add(bt=new Button("Draw"));
        bt.addActionListener(new ActionListener(){
           public void actionPerformed(ActionEvent e){
               int i;
               for (i=0; i < DOUBLENUM ;i++){
                  gui[i].dval=new Double(gui[i].tf.getText()).doubleValue();
               }
               repaint();
           }
        });
    }
  //ここに計算と描画のプログラムを記述
    public void paint(Graphics g){
	double a=20,pi=3.1416,t;
	int    x0=50,y10=100,y20=200,y30=320,y1,y2,y3,i,x;
	for(i=0;i<1000;i++){
	    t=(double)i;
	    x=(int)t/2;
	    y1=(int)func1(a,pi,t);y2=(int)func2(a,pi,t);y3=y1+y2;
	    g.drawLine(x+x0,-y1+y10,x+x0,-y1+y10);
	    g.drawLine(x+x0,-y2+y20,x+x0,-y2+y20);
	    g.drawLine(x+x0,-y3+y30,x+x0,-y3+y30);
	}

    }
    public int func1(double a,double pi,double t){
	double temp;
	temp=a*Math.sin(2*pi*(gui[0].dval/1000)*t);
	return (int)temp;
    }
    public int func2(double a,double pi,double t){
	double temp;
	temp=a*Math.sin(2*pi*(gui[1].dval/1000)*t);
	return (int)temp;
    }
    class Gui_double{
        Label la;
        TextField tf;
        double dval;
        public Gui_double(String st1,String st2,int d_field){
            add(la=new Label(st1));
            add(tf=new TextField(st2,d_field));
        }
    }
}






