import java.awt.Button;
import java.awt.Color;
import java.awt.Font;
import java.awt.Frame;
import java.awt.Label;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.List;
public class myFrame extends Frame
{
String s=null;
TextField tf1,tf2,tf3,tf4;
public myFrame()
{
setBackground(Color.black); //窗口设置
setBounds(200, 100,800 ,500);
this.setTitle("复数—计算器");
this.setLayout(null);
this.setResizable(false);
this.addWindowListener(new Windows());
Button b7=new Button("7"); //按键设置
b7.setBounds(50, 200, 100, 50);
b7.setVisible(true);
this.add(b7);
b7.setFont(new Font("隶书",Font.BOLD,35));
b7.addActionListener(new Monitor2());
setVisible(true);
Button b8=new Button("8");
b8.setBounds(200, 200, 100, 50);
b8.setVisible(true);
this.add(b8);
b8.setFont(new Font("隶书",Font.BOLD,35));
b8.addActionListener(new Monitor2());
setVisible(true);
Button b9=new Button("9");
b9.setBounds(350, 200, 100, 50);
b9.setVisible(true);
this.add(b9);
b9.setFont(new Font("隶书",Font.BOLD,35));
b9.addActionListener(new Monitor2());
setVisible(true);
Button bj=new Button("+");
bj.setBounds(550, 200, 100, 50);
bj.setVisible(true);
this.add(bj);
bj.setFont(new Font("隶书",Font.BOLD,35));
bj.addActionListener(new Monitor2());
setVisible(true);
Button b4=new Button("4");
b4.setBounds(50, 275, 100, 50);
b4.setVisible(true);
this.add(b4);
b4.setFont(new Font("隶书",Font.BOLD,35));
b4.addActionListener(new Monitor2());
setVisible(true);
Button b5=new Button("5");
b5.setBounds(200, 275, 100, 50);
b5.setVisible(true);
this.add(b5);
b5.setFont(new Font("隶书",Font.BOLD,35));
b5.addActionListener(new Monitor2());
setVisible(true);
Button b6=new Button("6");
b6.setBounds(350, 275, 100, 50);
b6.setVisible(true);
this.add(b6);
b6.setFont(new Font("隶书",Font.BOLD,35));
b6.addActionListener(new Monitor2());
setVisible(true);
Button br=new Button("-");
br.setBounds(550, 275, 100, 50);
br.setVisible(true);
this.add(br);
br.setFont(new Font("隶书",Font.BOLD,35));
br.addActionListener(new Monitor2());
setVisible(true);
Button b1=new Button("1");
b1.setBounds(50, 350, 100, 50);
b1.setVisible(true);
this.add(b1);
b1.setFont(new Font("隶书",Font.BOLD,35));
b1.addActionListener(new Monitor2());
setVisible(true);
Button b2=new Button("2");
b2.setBounds(200,350, 100, 50);
b2.setVisible(true);
this.add(b2);
b2.setFont(new Font("隶书",Font.BOLD,35));
b2.addActionListener(new Monitor2());
setVisible(true);
Button b3=new Button("3");
b3.setBounds(350, 350, 100, 50);
b3.setVisible(true);
this.add(b3);
b3.setFont(new Font("隶书",Font.BOLD,35));
b3.addActionListener(new Monitor2());
setVisible(true);
Button bc=new Button("*");
bc.setBounds(550, 350, 100, 50);
bc.setVisible(true);
this.add(bc);
bc.setFont(new Font("隶书",Font.BOLD,35));
bc.addActionListener(new Monitor2());
setVisible(true);
Button bn=new Button("0");
bn.setBounds(50, 425, 100, 50);
bn.setVisible(true);
this.add(bn);
bn.setFont(new Font("隶书",Font.BOLD,35));
bn.addActionListener(new Monitor2());
setVisible(true);
Button bd=new Button(".");
bd.setBounds(200,425, 100, 50);
bd.setVisible(true);
this.add(bd);
bd.setFont(new Font("隶书",Font.BOLD,30));
bd.addActionListener(new Monitor2());
setVisible(true);
Button bi=new Button("i");
bi.setBounds(350,425, 100, 50);
bi.setVisible(true);
this.add(bi);
bi.setFont(new Font("隶书",Font.BOLD,35));
bi.addActionListener(new Monitor2());
setVisible(true);
Button bkz=new Button("(");
bkz.setBounds(550,425, 100, 50);
bkz.setVisible(true);
this.add(bkz);
bkz.setFont(new Font("隶书",Font.BOLD,35));
bkz.addActionListener(new Monitor2());
setVisible(true);
Button bky=new Button(")");
bky.setBounds(675,425, 100, 50);
bky.setVisible(true);
this.add(bky);
bky.setFont(new Font("隶书",Font.BOLD,35));
bky.addActionListener(new Monitor2());
setVisible(true);
Button bde=new Button("=");
bde.setBounds(675,300, 100, 100);
bde.setVisible(true);
this.add(bde);
bde.setFont(new Font("隶书",Font.BOLD,35));
setVisible(true);
bde.addActionListener(new Monitor());
Button bAC=new Button("AC");
bAC.setBounds(675,200, 100, 30);
bAC.setVisible(true);
this.add(bAC);
bAC.setFont(new Font("隶书",Font.BOLD,35));
setVisible(true);
bAC.addActionListener(new Monitor2());
Button bDEL=new Button("DEL");
bDEL.setBounds(675,250, 100, 30);
bDEL.setVisible(true);
this.add(bDEL);
bDEL.setFont(new Font("隶书",Font.BOLD,35));
setVisible(true);
bDEL.addActionListener(new Monitor2());
Button bclear=new Button("clear");
bclear.setBounds(735,140, 40, 30);
bclear.setVisible(true);
this.add(bclear);
// bclear.setFont(new Font("隶书",Font.BOLD,35));
setVisible(true);
bclear.addActionListener(new Monitor2());
Label lb=new Label("结果为:"); //标签设置
lb.setBounds(50,125,125,50);
lb.setBackground(Color.white);
this.add(lb);
lb.setFont(new Font("隶书",Font.BOLD,35));
setVisible(true);
tf1=new TextField (); //文本框设置
tf1.setBounds(50, 50, 700, 50);
tf1.setVisible(true);
add(tf1);
tf1.setFont(new Font("隶书",Font.BOLD,35));
tf2=new TextField ();
tf2.setBounds(400, 125, 325, 50);
tf2.setVisible(true);
tf2.setFont(new Font("隶书",Font.BOLD,35));
add(tf2);
tf3=new TextField ();
tf3.setFont(new Font("隶书",Font.BOLD,35));
tf3=new TextField ();
tf3.setBounds(185, 135, 80, 30);
tf3.setVisible(true);
add(tf3);
tf3.setFont(new Font("隶书",Font.BOLD,15));
tf4=new TextField ();
tf4=new TextField ();
tf4.setBounds(275, 135, 110, 30);
tf4.setVisible(true);
add(tf4);
tf4.setFont(new Font("隶书",Font.BOLD,15));
}
public static void main(String[] args) //主方法
{
//String s = "(-4-i)+ (-5-8i)+(5-34i)*(-7-9i)+(8+9i)+(-1)+(-9i)";
myFrame mmm=new myFrame();
}
public void set(String str,String angle,String length) //设置字符串
{
tf2.setText(str);
tf3.setText(angle+"°");
tf4.setText(length+"");
}
public S
评论0