//不知是不是这个意思?
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.io.*;public class Test extends JFrame  {
  JList list = new JList();
  JScrollPane sp = new JScrollPane(list);
  Vector data = new Vector();
  JButton button = new JButton("load");
  ButtonListener blistener = new ButtonListener();
  
  public Test(){
  super("Test");
  addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {System.exit(0);}
      });
  list.setVisibleRowCount(10);
  
  button.addActionListener(blistener);  Container contentPane = getContentPane(); 
  contentPane.add(sp,BorderLayout.CENTER);
  contentPane.add(button,BorderLayout.NORTH);  pack();
  setSize(410,300);
  setLocation(200,150);
  setResizable(false);
  setVisible(true);
  }
  public void loadData(String filename) { 
    File inputFile = new File(filename); 
    if (!inputFile.exists()) { 
      try{}
      catch(Exception e){}
    } 
    FileInputStream input = null;
      try { input = new FileInputStream(inputFile); 
      } 
      catch(Exception ioe){ } 
      try { BufferedReader reader = new BufferedReader( new InputStreamReader(input)); 
            if(!data.isEmpty())data.removeAllElements();
            while (true) { 
                String currentLine = reader.readLine(); 
                if (currentLine==null) 
                    break; 
                data.addElement(currentLine); 
                list.setListData(data);
            }        
      } 
    catch (Exception ioe) { 
    } 
  } 
public static void main(String args[]) { 
    new Test().show();
}class ButtonListener implements ActionListener {
    public void actionPerformed (ActionEvent ae) { 
      Object obj = ae.getSource(); 
      if (obj == button) {loadData("loadtry.txt");//写入文件路径和文件名
    }  
  }
}
}