请各位java师哥师姐:"救命啊!救命啊!"救人一命深造七级佛图!

来源:百度知道 编辑:UC知道 时间:2024/05/30 17:37:58
fis=new FileInputStream(filename);这里有错误!帮忙改正!
以下是程序代码!
import javax.swing.*;

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

import java.io.*;

public class MyReader2 extends JFrame
implements ActionListener
{
JButton butopen,butclose;
JTextArea ta;

public MyReader2()
{
Icon iconopen=new ImageIcon("open.jpg");
Icon iconclose=new ImageIcon("close.jpg");
butopen=new JButton("打开",iconopen);
butopen.addActionListener(this);

butclose=new JButton("输入文件名:",iconclose);
butclose.addActionListener(this);

ta=new JTextArea(10,10);
JScrollPane aa=new JScrollPane(ta);

JPanel p1=new JPanel();
p1.add(butopen);
p1.add(butclose);

this.getContentPane().add(p1,"North");
//this.getContentPane().add(ta);
this.getContentPane().add(aa);

你没有定义 filename 这个变量啊!呵呵呵!

filename=""; 作用域问题。
把这句话放到if外面。

filename是个空的.你说IO流从哪里读数据呢.对吧.

请各位java师哥师姐:"救命啊!救命啊!"救人一命深造七级佛图!
你写错啦,,应该是 "救人一命胜造七级浮屠"才对。。

filename没有初始化,会报问题

………………