余洁妮吧 关注:8贴子:840
  • 3回复贴,共1
package inter;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
public class Cal implements ActionListener{
JFrame jf;
JTextField op1,op2,result;
JLabel jl;
JButton **;
public Cal()
{
jf=new JFrame("计算器");
op1=new JTextField(5);
op2=new JTextField(5);
result=new JTextField(5);
jl=new JLabel("+");
**=new JButton("=");
jf.setLayout(new FlowLayout());111
jf.add(op1);
jf.add(jl);
jf.add(op2);
jf.add(**);
jf.add(result);
jf.setSize(300,200);
jf.setVisible(true);
**.addActionListener(this);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
new Cal();
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(e.getSource()==**)
{
int x=Integer.parseInt(op1.getText().trim());
int y=Integer.parseInt(op2.getText().trim());
int r=x+y;
result.setText(r+"");
}
}


IP属地:江西1楼2018-06-12 15:09回复
    被屏蔽的是**


    IP属地:江西来自Android客户端2楼2018-06-12 15:11
    回复
      该楼层疑似违规已被系统折叠 查看此楼


      IP属地:江西来自Android客户端3楼2018-06-12 15:11
      回复
        该楼层疑似违规已被系统折叠 查看此楼


        IP属地:江西4楼2018-06-14 09:43
        回复