作业帮 > 综合 > 作业

java的类 谢谢写一个计算器类Calculator,完成对两个数的加减乘除运算。

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/13 10:11:41
java的类 谢谢
写一个计算器类Calculator,完成对两个数的加减乘除运算。
import java.awt.*;
import java.awt.event.*;
public class TestWindowClose {
public static void main(String args[]) {
new MyFrame55("MyFrame");
}
}
class MyFrame55 extends Frame {
MyFrame55(String s) {
super(s);
setLayout(null);
setBounds(300, 300, 400, 300);
this.setBackground(new Color(204, 204, 255));
setVisible(true);
//this.addWindowListener(new MyWindowMonitor());

this.addWindowListener(
new WindowAdapter() {
public void windowClosing(WindowEvent e) {
setVisible(false);
System.exit(-1);
}
});

}
/*以下是内部类的写法
class MyWindowMonitor extends WindowAdapter {
public void windowClosing(WindowEvent e) {
setVisible(false);
System.exit(0);
}
}
*/
}