package jiemian;
import java.awt.*;
import java.awt.event.*;
import java.util.Date;import jiemian.MyFrame6.Monitor1;
import jiemian.MyFrame6.Monitor2;
import jiemian.MyFrame6.MyWindowMonitor;public class Calculate {
public static int N=0,n=0,t=0;
public static double m[][],x;
public static void main(String []args){
new MyFrame6();
new MyFrame1();

}
}
class MyFrame1 extends Frame{
Panel p1,p2,p3;
Label l1,l2,l3;
TextField t1,t2,t3;
MyFrame1(){
//super("插值计算");
p1 = new Panel();
p2 = new Panel();
p3 = new Panel();
l1 = new Label("欢迎使用插值计算软件");
l2 = new Label("你所求的插值次数:");
l3 = new Label("你好");
t1 = new TextField(4);
t2 = new TextField(22);
t3 = new TextField(22);
Date date = new Date();
setBackground(Color.PINK);
t2.setText(date.toString());
Label l3 = new Label("时间:");
add(p1,BorderLayout.NORTH);
add(p2,BorderLayout.CENTER);
add(p3,BorderLayout.SOUTH);
p1.setLayout(new FlowLayout());
p2.setLayout(new FlowLayout());
p3.setLayout(new FlowLayout());
p1.add(l1);
p2.add(l2);
p3.add(l3);
p2.add(t1);

p2.add(t3);

p3.add(t2);
setLocation(300,210);
pack();
setResizable(false);
setVisible(true);
System.out.println("hello3");
setSize(300,200);
t1.addActionListener(new Monitor());
//t1.getText();
this.addWindowListener(new MyWindowMonitor ());
while(true){
Date d = new Date();
t2.setText(d.toString());
try {
Thread.sleep(1000);
}
catch(InterruptedException e) {
t2.setText("日期获得错误");
  
}
}

}
class MyFrame6 extends Frame{
MyFrame6(){
super("插值计算软件");
Panel p1 = new Panel();
Panel p2 = new Panel();

Button button1 = new Button("拉格朗日插值");
Button button2 = new Button("牛顿插值");
Label l1 = new Label("你选择的插值计算方法:");

add(p1,BorderLayout.NORTH);
add(p2,BorderLayout.CENTER);
p1.setLayout(new FlowLayout());
p2.setLayout(new FlowLayout());
p1.add(l1);
p2.add(button1);
p2.add(button2);
setBackground(Color.PINK);
//setLocation(300,210);

setResizable(false);
setSize(300,200);

setVisible(true);
//addWindowListener(new MyWindowMonitor ());
button1.addActionListener(new Monitor1());
button2.addActionListener(new Monitor2());
}

class Monitor1 implements ActionListener{


public void actionPerformed(ActionEvent e){

setVisible(false);

new MyFrame1();//就是这行调用时错误,而直接运行MyFrame1没问题。这是怎么回事,先谢谢。




}
}
class Monitor2 implements ActionListener{


public void actionPerformed(ActionEvent e){
System.out.println("Hello2");
}
}

}