importjava.awt.EventQueue;importjavax.swing.JFrame;importjava.awt.BorderLayout;importjavax.swing.JLabel;importjava.awt.Font;importjavax.swing.SwingConstants;importjavax.swing.JPanel;importjava.awt.GridLayout;importjavax.swing.JTextArea;importjavax.swing.JProgressBar;importjavax.swing.border.EmptyBorder;importjavax.swing.JButton;importjava.awt.event.ActionListener;importjava.awt.event.ActionEvent;/***@author李祖林*/
public class CalFrame implementsActionListener{privateJFrame frame;
JTextArea textA,textB;
JProgressBar progressBar;
JButton button;publicCalFrame() {
frame= newJFrame();
frame.setBounds(100, 100, 755, 300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(new BorderLayout(0, 0));
JLabel label= new JLabel("\u591A\u7EBF\u7A0B \u8BA1\u7B971!+2!+...+12!");
label.setHorizontalAlignment(SwingConstants.CENTER);
label.setFont(new Font("宋体", Font.BOLD, 18));
frame.getContentPane().add(label, BorderLayout.NORTH);
JPanel panel= newJPanel();
frame.getContentPane().add(panel, BorderLayout.CENTER);
panel.setLayout(new GridLayout(3, 2, 0, 0));
JLabel label_1= new JLabel("\u8BA1\u7B97\u8FC7\u7A0B");
label_1.setFont(new Font("宋体", Font.BOLD, 18));
label_1.setHorizontalAlignment(SwingConstants.CENTER);
panel.add(label_1);
textA= newJTextArea();
textA.setFont(new Font("Courier New", Font.BOLD, 15));
panel.add(textA);
JLabel label_2= new JLabel("\u8FDB\u5EA6\u6761");
label_2.setHorizontalAlignment(SwingConstants.CENTER);
label_2.setFont(new Font("宋体", Font.BOLD, 18));
panel.add(label_2);
progressBar= newJProgressBar();
progressBar.setMaximum(12);
panel.add(progressBar);
JLabel label_3= new JLabel("\u8BA1\u7B97\u7ED3\u679C");
label_3.setHorizontalAlignment(SwingConstants.CENTER);
label_3.setFont(new Font("宋体", Font.BOLD, 18));
panel.add(label_3);
textB= newJTextArea();
textB.setFont(new Font("Courier New", Font.BOLD, 18));
panel.add(textB);
JPanel panel_1= newJPanel();
frame.getContentPane().add(panel_1, BorderLayout.SOUTH);
button= new JButton("\u5F00\u59CB");
button.setFont(new Font("宋体", Font.BOLD, 18));
panel_1.add(button);button.addActionListener(this);
frame.setVisible(true);
}public voidactionPerformed(ActionEvent e) {/*计算线程 自启动*/CalThread calThread= newCalThread();/*读取线程*/ReadThread readThread= new ReadThread(this); //此处的this是CalFrame类的对象
Thread thread = new Thread(readThread); //非自启动:构造扩展线程类的对象,通过Thread()传该类得以实现线程
thread.start();
}public static voidmain(String[] args) {
CalFrame calFrame= newCalFrame();
}
}