package calculator;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;
public class myCalculator {
public static void main(String[] args) {
new calculatorJFrame2();
}
}
class calculatorJFrame2 extends JFrame implements ActionListener{
//按钮
JButton bu1, bu2, bu3, bu4, bu5, bu6, bu7, bu8, bu9, bu10, bu11, bu12, bu13, bu14, bu15, bu16,bu17;
//文本域
JTextField text;
//容器
JPanel jp1,jp2,jp3,jp4;
public void init(){
//标题
this.setTitle("简单的计算器");
//位置
this.setLocationRelativeTo(null);
//窗体不可放大
this.setResizable(false);
//自动适应窗体大小
this.pack();
//关闭
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
//窗体可见
this.setVisible(true);
}
public calculatorJFrame2(){
//初始化按钮
bu1=new JButton("7");
bu2=new JButton("8");
bu3=new JButton("9");
bu4=new JButton("/");
bu5=new JButton("4");
bu6=new JButton("5");
bu7=new JButton("6");
bu8=new JButton("*");
bu9=new JButton("1");
bu10=new JButton("2");
bu11=new JButton("3");
bu12=new JButton("-");
bu13=new JButton("0");
bu14=new JButton(".");
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;
public class myCalculator {
public static void main(String[] args) {
new calculatorJFrame2();
}
}
class calculatorJFrame2 extends JFrame implements ActionListener{
//按钮
JButton bu1, bu2, bu3, bu4, bu5, bu6, bu7, bu8, bu9, bu10, bu11, bu12, bu13, bu14, bu15, bu16,bu17;
//文本域
JTextField text;
//容器
JPanel jp1,jp2,jp3,jp4;
public void init(){
//标题
this.setTitle("简单的计算器");
//位置
this.setLocationRelativeTo(null);
//窗体不可放大
this.setResizable(false);
//自动适应窗体大小
this.pack();
//关闭
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
//窗体可见
this.setVisible(true);
}
public calculatorJFrame2(){
//初始化按钮
bu1=new JButton("7");
bu2=new JButton("8");
bu3=new JButton("9");
bu4=new JButton("/");
bu5=new JButton("4");
bu6=new JButton("5");
bu7=new JButton("6");
bu8=new JButton("*");
bu9=new JButton("1");
bu10=new JButton("2");
bu11=new JButton("3");
bu12=new JButton("-");
bu13=new JButton("0");
bu14=new JButton(".");