import javax.swing.border.*; snippetPath = "C:\\Snippets\\"; void InsertText ( String filename ) { File inputFile = pathToFile(filename); BufferedReader in = new BufferedReader( new FileReader(inputFile)); String text = ""; String s; while ((s=in.readLine()) != null) { text += s + "\n"; } textArea.setSelectedText(text); } void actionPerformed(e) { if(e.getSource() == ok) { Snippet selection = (Snippet)list.getSelectedValue(); path = snippetPath + selection.filename; InsertText( path ); } dialog.dispose(); } class Snippet { String filename; String prettyName; Snippet ( String filename, String prettyName ) { this.filename = filename; this.prettyName = prettyName; } String toString () { return prettyName; } } // Convert _'s to spaces, and remove the extension String makePrettyName ( String filename ) { int dotIndex = filename.lastIndexOf( "." ); String prettyName = filename.substring(0,dotIndex); prettyName = prettyName.replace ( "_", " " ); return prettyName; } void addAllSnippetsToList ( Vector names, String pathToSnippets ) { File dir = new File(pathToSnippets); String[] children = dir.list(); for (int i=0; i