JAVA实现将一个文本文件中的所有信息输出

来源:百度知道 编辑:UC知道 时间:2024/04/30 04:37:09
一下是我自己写的一个简单类,然后到按钮时间时想实现点击按钮,然后将其他模块保存在一个文本文件的所有学生信息全部显示出来,现在button事件不会实现输出,请高手给帮下忙,新手,分不多,见谅。多谢帮助
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.io.*;
public class AllSudent extends Frame implements ActionListener{
TextArea text1;
Button button;
void WindowTextArea(){
setLayout(new FlowLayout());
button=new Button("确定查询");
add(text1);

add(button);
text1.setEditable(false);

button.addActionListener(this);
setBounds(100,100,350,160);
setVisible(true);
validate();
}

public void actionPerformed(ActionEvent e){
if(e.getSource()==button){

}

}
}

1.兄弟首先跟你提点建议:以后问问题,不要有那么多错别字吗,还有说清楚一点,不要让别人去猜你的意图
2.你代码问题太多了,不知道写WindowTextArea 有何意图?????
3.我帮你改了一下,不知道合不合你意啊!
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.io.*;
public class AllSudent extends Frame implements ActionListener{
TextArea text1=new TextArea();
Button button;
void WindowTextArea(){
setLayout(new FlowLayout());
button=new Button("确定查询");
add(text1);

add(button);
text1.setEditable(false);

button.addActionListener(this);
setBounds(100,100,350,160);
setVisible(true);
validate();
}

public static void main(String[] args) {
(new AllSudent()).WindowTextArea();
}
public void actionPerformed(ActionEvent e){
if(e.getSource()==button){
//设C:\\1.txt为存储学生信息的文件
try {
FileReader fileReader=new FileReader("C:\\1.txt"); //创建文件