It seems you want to populate the text area with the content of a text file. But to do that you read every line of the text file and do
jta.replaceSelection(text);
But as its name and javadoc indicates, replaceSelection()
replaces the text selected by the user in the text area. What you simply want is to clear the text area and append the text to the text area:
jta.setText(""); // clear
while (scan.hasNextLine()){
String line = scan.nextLine();
jta.append(line);
jta.append("\n");
}
Or, easier:
jta.read(new FileReader(userFile, null);
which will read everything from the file for you and populate the text area with its content.