请在我原来的代码上添加简单计算器的加减乘除功能(简单点的,java)
package Firstproject;import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.GridLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
public class SimpleCounter {
public void Counter(){
JFrame jf=new JFrame("SimpleCounter");
JPanel shuru=new JPanel();//创建输入框面板
JTextField txet=new JTextField();
JPanel qingchu=new JPanel();
JPanel shuzi=new JPanel();
//输入框文本的基本设置
txet.setText(".0");
txet.setColumns(20);
txet.setHorizontalAlignment(SwingConstants.RIGHT);
shuru.add(txet);
txet.setEditable(false);
jf.add(shuru,BorderLayout.NORTH);
//清楚 2个按钮的基本设置
JButton C=new JButton();
JButton Bs=new JButton();
C.setText("清零");
Bs.setText("退格");
qingchu.add(C);
qingchu.add(Bs);
jf.add(qingchu,BorderLayout.CENTER);
//网格数字的基本设置
GridLayout g=new GridLayout(4,4,5,5);
shuzi.setLayout(g);
jf.add(shuzi,BorderLayout.SOUTH);
String[][] ButtonNames={{ "1","2","3","+",},{"4","5","6","-",},{"7","8","9","*"},{"0",".","=","/",}};
JButton[] inputButtonNames=new JButton[20];
for(int hang=0;hang<ButtonNames.length;hang++){
for(int lie=0;lie<ButtonNames.length;lie++){
inputButtonNames[hang*5+lie]=new JButton(ButtonNames[hang][lie]);
inputButtonNames[hang*5+lie].setName(hang+""+lie);
shuzi.add(inputButtonNames[hang*5+lie]);
}
}
//窗体的基本设置
jf.setSize(250, 250);
jf.setLocation(500, 200);
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jf.setVisible(true);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
SimpleCounter sc=new SimpleCounter();
sc.Counter();
}
}