import java.io.*; import java.awt.*; import java.awt.event.*; public class DirectoryList extends Frame implements ActionListener { TextArea text; List list; public DirectoryList(String[] files) { super("DirectoryList Window"); setSize(400, 500); // ***>>> Set the size // ***>>> Create the list // ***>>> Add this object as an action listener for (int i = 0; i < files.length; i++) list.add(files[i]); add(list, BorderLayout.NORTH); add(text = new TextArea(10, 40), BorderLayout.CENTER); // ***>>> Handle the window-closing operation here } public void actionPerformed(ActionEvent e) { // ***>>> Handle the double-click operation here } public void displayFile(String fileName) { FileReader f = null; BufferedReader br = null; try { f = new FileReader(fileName); br = new BufferedReader(f); } catch (IOException e) { text.append("Cannot open file: " + fileName); } try { String line = br.readLine(); while (line != null) { text.append(line + "\n"); line = br.readLine(); } } catch (EOFException e) { // no problem, end of file here } catch (IOException e) { text.append("IO error reading: " + fileName); } } }