importjavax.swing.*;importjava.awt.*;importjava.awt.event.*;importjava.sql.Date;importjava.text.SimpleDateFormat;importjava.util.TimerTask;importjava.util.Calendar;import...
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.Date;
import java.text.SimpleDateFormat;
import java.util.TimerTask;
import java.util.Calendar;
import java.util.Timer;
public class Calculationer extends JFrame implements ActionListener {
private JPanel panel = new JPanel();
private JTextField text1 = new JTextField();
private JTextField text2,field;
private Calendar c=Calendar.getInstance();
private JButton[] number = new JButton[11];
private JButton bt1, bt2, bt3, bt4, bt5, bt6, bt7, bt8, bt9, bt10,bt11;
String string = "";
Label labelSpace; //labelSpace单纯做摆设,控制面板的形状
Label nowtime;//定义一个系统时间标签,用于显示获取当前系统时间
JLabel label=new JLabel();
public static void setTime() //设置时间
{
}
public Calculationer() {
setTitle("简单计算器");
this.setResizable(false);
for (int i = 0; i < 10; i++) {
number[i] = new JButton("" + i);
number[i].addActionListener(this);
}
bt1 = new JButton(".");
bt1.addActionListener(this);
bt2 = new JButton("=");
bt2.addActionListener(this);
bt3 = new JButton("+");
bt3.setForeground(Color.blue);
bt3.addActionListener(this);
bt4 = new JButton("—");
bt4.addActionListener(this);
bt4.setForeground(Color.blue);
bt5 = new JButton("X");
bt5.addActionListener(this);
bt5.setForeground(Color.blue);
bt6 = new JButton("÷");
bt6.addActionListener(this);
bt6.setForeground(Color.blue);
bt7 = new JButton("√");
bt7.setForeground(Color.red);
bt7.addActionListener(this);
bt8 = new JButton("Re");
bt8.addActionListener(this);
bt8.setForeground(Color.red);
bt9 = new JButton("㎡");
bt9.addActionListener(this);
bt9.setForeground(Color.red);
bt10 = new JButton("/");
bt10.addActionListener(this);
bt10.setForeground(Color.cyan);
bt11 = new JButton("Time");
bt11.setForeground(Color.black);
panel.setLayout(new GridLayout(5,5,3,3));
text2=new JTextField(" 感谢使用 !");
field=new JTextField(50);
field.addActionListener(this);
text1.setEditable(false);
field.setEditable(false);
text2.setEditable(false);
展开