java 减法基础_java 加减乘除基础代码问题

packagecmj518_3;importjava.awt.*;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;importjavax.swing.*;publicclassCalculate{publicstaticvoidmain(String...

package cmj518_3;import java.awt.*;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.*;public class Calculate {public static void main(String args[]) {new Calculate();}public Calculate() {JFrame jf = new JFrame("Incrementor");JPanel jp= new JPanel();JTextField jtf1;JTextField jtf2;JTextField jtf3;JTextArea jta;JScrollPane jsp;JButton jb = new JButton();Container contentPane = jf.getContentPane();jp.setLayout(new FlowLayout());contentPane.setLayout(new BorderLayout());jf.setSize(400, 200);jp.setBackground(Color.WHITE);jp.setLayout(new FlowLayout());contentPane.add(jp); jtf1 = new JTextField("",8);jtf2 = new JTextField("",5);jtf3 = new JTextField("",8);jta = new JTextArea("");jsp=new JScrollPane();jta.setLineWrap(true);jta.setSize(2000,2000);jta.setBackground(Color.blue);jp.add(jtf1);jp.add(jtf2);jp.add(jtf3);jp.add(jta);jp.add(jsp);jb= new JButton("计算");jp.add(jb);contentPane.add(jp);jf.setVisible(true);//设置显示jb.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {int num1= Integer.valueOf(jtf1.getText());int num2 = Integer.valueOf(jtf3.getText());String s=jtf2.getText();double result =0;if (s=="*"){result= num1*num2;}else if (s=="/"){result= num1/num2;}else if (s=="+"){result= num1+num2;}else if(s=="-"){result= num1-num2;}String ma=String.valueOf(num1+num2);jtf1.setText("");jtf2.setText("");jtf3.setText(ma);String output=String.valueOf(result); jta.setText(output); }});}}哪里出错了,为啥打不开

展开

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值