作者在 2008-11-25 18:56:17 发布以下内容
import java.io.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class 记事本
{ public static void main(String args[]) throws IOException{
JFrame frame=new JFrame("记事本");
frame.setLayout(new GridLayout(0,1));
JButton button1=new JButton("22");
JPanel panel=new JPanel();
panel.add(button1);
final JTextArea textArea=new JTextArea(10,30);
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class 记事本
{ public static void main(String args[]) throws IOException{
JFrame frame=new JFrame("记事本");
frame.setLayout(new GridLayout(0,1));
JButton button1=new JButton("22");
JPanel panel=new JPanel();
panel.add(button1);
final JTextArea textArea=new JTextArea(10,30);
frame.add(panel);
frame.pack();
frame.setVisible(true);
button1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
try{
文件 file=new 文件("c:\\1.TXT");
字符文件读 reader=new 字符文件读(file);
int c;
c=reader.读字符();
while(c!=-1){
textArea.append(Character.toString((char)c));
c=reader.读字符();
}
reader.关闭();
}
catch(IOException ex){
System.out.println(ex.toString());
}
}
});
button1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
try{
文件 file=new 文件("c:\\1.TXT");
字符文件写 writer=new 字符文件写(file);
String s="有个性,没人性";
char[] cs=s.toCharArray();
for(char c:cs){
writer.写字符((int)c);
}
writer.关闭();
}
catch(IOException ex){
System.out.println(ex.toString());
}
}
});
}
}
frame.setVisible(true);
button1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
try{
文件 file=new 文件("c:\\1.TXT");
字符文件读 reader=new 字符文件读(file);
int c;
c=reader.读字符();
while(c!=-1){
textArea.append(Character.toString((char)c));
c=reader.读字符();
}
reader.关闭();
}
catch(IOException ex){
System.out.println(ex.toString());
}
}
});
button1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
try{
文件 file=new 文件("c:\\1.TXT");
字符文件写 writer=new 字符文件写(file);
String s="有个性,没人性";
char[] cs=s.toCharArray();
for(char c:cs){
writer.写字符((int)c);
}
writer.关闭();
}
catch(IOException ex){
System.out.println(ex.toString());
}
}
});
}
}