import javax.swing.*;
package a;
import java.awt.event.*;
import java.awt.*;
public class Calculator1 extends Frame implements ActionListener {
Frame frame;
Panel panel;
TextField t;
Button[] button;
StringBuffer str=new StringBuffer("");
double x, y;
int z;
Calculator1()
{
frame=new Frame();
frame.setLayout(new BorderLayout());
MenuBar mb=new MenuBar();
Menu menu1=new Menu("编辑(E)");
Menu menu2=new Menu("查看(v)");
Menu menu3=new Menu("帮助(H)");
MenuItem mi1=new MenuItem("复制(C) Ctrl+C ");
MenuItem mi2=new MenuItem("粘贴(V) Ctrl+V ");
MenuItem m2=new MenuItem("退出");
m2.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e2)
{
System.exit(0);
}
});
MenuItem mi3=new MenuItem("标准型(T) ");
MenuItem mi4=new MenuItem("科学型(S) ");
MenuItem mi5=new MenuItem("数据分组(I) ");
MenuItem mi6=new MenuItem("帮助主题(H) ");
MenuItem mi7=new MenuItem("关于计算器(A) ");
String s[]={"My","love","退格","CE","C","7","8","9","+/-","sqrt","4","5","6","/","%","1","2","3","-","0","*","1/x",".","+","="};
button=new Button[s.length];
panel=new Panel();
panel.setLayout(new GridLayout(5,5));
t=new TextField("0",27);
t.setEnabled(false);
for(int i=0;i<button.length;i++)
{
button[i]=new Button(s[i]);
button[i].setForeground(Color.blue);
panel.add(button[i]);
}
for(int i=0;i<button.length;i++)
{
button[i].addActionListener(this);
// button[i].setBackground(new Color(194,171,245));
}
button[0].addMouseListener(new MouseAdapter(){
public void mouseEntered(MouseEvent e){
button[0].setBackground(Color.cyan);
}
});
button[0].addMouseListener(new MouseAdapter(){
public void mouseExited(MouseEvent e){
// button[0].setBackground());
}});
mb.add(menu1);
mb.add(menu2);
mb.add(menu3);
mb.add(menu1);
mb.add(menu2);
mb.add(menu3);
menu1.add(mi1);
menu1.add(mi2);
menu1.add(m2);
menu2.add(mi3);
menu2.add(mi4);
menu2.add(mi5);
menu3.add(mi6);
menu3.add(mi7);
frame.setMenuBar(mb);
frame.setBounds(300,300,260,370);
frame.add(t,BorderLayout.NORTH);
frame.add(panel,BorderLayout.CENTER);
frame.setBackground(Color.blue);
frame.setResizable(false);
frame.setVisible(true);
frame.addWindowListener(new WindowAdapter(){