I'm wondering if you're making this overly complex. All you need to do is use the Scanner class to read the text from your file. And then as Tim mentioned in his comment you could load whatever Scanner takes in into a list structure and then print out the lines from that (though honestly you could even do it without the list storage structure, though it does make manipulating it easier). And then yeah use setText method for a text pane and off you go.
The ListInterface could be replaced with any storage type. Again Tim suggested a list that would work just as well. You could also just use a simple array, though then you wouldn't be able to write your own methods to interface with it as nicely.
ListInterface<String> fileBag = new ListArray<>();
try
{
/*
* Open file fileName with Scanner
* add all entries fron the file somefile.txt into fileBag
* Close Scanner object
*/
String fileName = "somefile.txt";
File file = new File(fileName);
Scanner scanner = new Scanner(file);
String line;
while (scanner.hasNextLine())
{
line = scanner.nextLine();
fileBag.add(line);
}
scanner.close();
}
catch(FileNotFoundException e)
{
System.out.println(e.getMessage());
System.exit(0);
}
If you don't know how to use interfaces and write your own methods for it in the class ListArray then replace
ListInterface<String> fileBag = new ListArray<>();
with
ArrayList<String> fileArrayList = new ArrayList<>(1000);
where 1000 should be a best guess at how big the array needs to be it doesn't need to be correct, the array will double its capacity if it goes to add and there isn't enough space, but this is an O(n) operation so it's best to avoid it if you have a good idea of how many lines your files will contain at maximum. Also replace:
fileBag.add(line);
with
with fileArrayList.add(line);