用JAVA编写一个GUI记事本程序,实现文本的输入,保存,修改,打开操作

来源:百度知道 编辑:UC知道 时间:2024/06/06 16:55:31
急…

保存时文件名如file.txt 文件格式也要输入
!!!注意该程序只能打开txt文件、java源程序文件、html文件等,
Word的doc文件是特殊格式文件不能用本程序打开。

import java.io.*;
import java.awt.*;
import java.awt.event.*;

public class jtxtfm{
public static void main(String args[]){
jtxtfrm fm=new jtxtfrm();
}
}

class jtxtfrm extends Frame implements ActionListener{
FileDialog op,sv;
Button btn1,btn2,btn3;
TextArea tarea;
jtxtfrm(){
super("读写文件");
setLayout(null);
setBackground(Color.cyan);
setSize(600,300);
setVisible(true);
btn1=new Button("打开");
btn2=new Button("保存");
btn3=new Button("关闭");
tarea=new TextArea("");
add(btn1);add(btn2);add(btn3);add(tarea);
tarea.setBounds(30,50,460,220);
btn1.setBounds(520,60,50,30);
btn2.setBounds(520,120,50,30);
btn3.setBounds(520,180,50,30);
op=new FileDialog(this,"打