📄 signatory.java
字号:
/**
* <p>Title:Signatory</p>
* <p>Discription:完成奥运倒计时的签名栏部分</p>
* @author DELL
* @version 1.0
*/
package Project1;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
public class Signatory extends Frame{
public JTextArea textarea1(){
JTextArea textarea1 = new JTextArea();
textarea1.setSize(150, 50);
textarea1.setEditable(true);
return textarea1;
}
public JTextArea textarea2(){
JTextArea textarea2 = new JTextArea();
File file=new File("F:\\example.txt");
try {
BufferedReader br =
new BufferedReader(
new InputStreamReader(
new FileInputStream("F:\\example.txt")));
String s=null;
try {
while((s=br.readLine())!=null)
{
textarea2.setText(s);
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
textarea2.setSize(300, 300);
textarea2.setEditable(true);
return textarea2;
}
public JButton button1(){//完成签名
JButton button1 = new JButton("完成签名");
button1.addActionListener(new button1Listener());
return button1;
}
public JButton button2(){//重新签名
JButton button2 = new JButton("重新签名");
button2.addActionListener(new button2Listener());
return button2;
}
public JButton button3(){//清除记录
JButton button3 = new JButton("清除记录");
button3.addActionListener(new button3Listener());
return button3;
}
class button3Listener implements ActionListener {
public void actionPerformed(ActionEvent e) {
textarea2().setText(null);
}
}
class button2Listener implements ActionListener {
public void actionPerformed(ActionEvent e) {
textarea1().setText(null);
}
}
class button1Listener implements ActionListener {
public void actionPerformed(ActionEvent e) {
PrintWriter backup;
FileOutputStream backupFileStream;
File backupFile;
backupFile = new File("F:\\example.txt");
String a = textarea1().getText();
try {
backupFileStream = new FileOutputStream(backupFile,true);
backup = new PrintWriter(backupFileStream,true);
backup.println(a);
} catch (FileNotFoundException ee) {
// TODO Auto-generated catch block
ee.printStackTrace();
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -