首页 > 其他 > 详细

实验十一

时间:2019-06-10 19:45:38      阅读:92      评论:0      收藏:0      [点我收藏+]

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


public class Jisuanqi extends Frame implements ActionListener{
public Jisuanqi() {
super("计算器");
Frame ff=new Frame("framework test");
ff.setSize(400,100);
ff.setLocation(300,240);
ff.setLayout(new FlowLayout());
//this.add(new TextField("10",8));
final TextField f1=new TextField("10",8);
ff.add(f1);

//this.add(new Label("+"));
Label l1=new Label("+");
ff.add(l1);
//this.add(new TextField("20",8));
TextField f2=new TextField("20",8);
ff.add(f2);
//this.add(new Button("="));
Button b1=new Button("=");
ff.add(b1);
//this.add(new TextField(10));
TextField f3=new TextField(10);
ff.add(f3);
ff.addWindowListener(new myclose());
ff.setVisible(true);
b1.addActionListener(new ActionListener()
{public void actionPerformed(ActionEvent e)
{double c;
String s1=f1.getText();
double a=Integer.parseInt(s1);
String s2=f2.getText();
double b=Integer.parseInt(s2);
c=a+b;
String m=String.valueOf(c);
f3.setText(m);

}

private double Integer(String s) {
// TODO Auto-generated method stub
return 0;
}
});

}

class myclose implements WindowListener{

public void windowActivated(WindowEvent arg0) {
// TODO Auto-generated method stub

}

public void windowClosed(WindowEvent arg0) {
// TODO Auto-generated method stub

}

public void windowClosing(WindowEvent arg0) {
// TODO Auto-generated method stub
System.exit(0);
}

public void windowDeactivated(WindowEvent arg0) {
// TODO Auto-generated method stub

}

public void windowDeiconified(WindowEvent arg0) {
// TODO Auto-generated method stub

}

public void windowIconified(WindowEvent arg0) {
// TODO Auto-generated method stub

}

public void windowOpened(WindowEvent arg0) {
// TODO Auto-generated method stub

}

}



public static void main(String[] args) {
// TODO 自动生成的方法存根
new Jisuanqi();
}


public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub

}


}

实验十一

原文:https://www.cnblogs.com/wuhui111/p/10999510.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!