Reading .txt contents and printing them to java GUI
As the title of my forum states, I'm looking for a way to read the contents of *.txt file, and display the in a Java JFrame using JLabel. I'm new to object oriented programming. I have a very solid background in procedural programming (mostly writing perl scripts), but Java is a little shaky to me. My text file has contents:
What is the best way to read that into a java program, and paste it to a GUI JFrame so that it's in the left hand corner. Thanks for any help
Re: Reading .txt contents and printing them to java GUI
You have two issues here: 1) reading in data from a file, and 2) displaying information in a Swing GUI. These two issues should be solved separately and then after being solved, combined. So for the reading in of data, consider using a Scanner object. For displaying multi-lined information, I prefer to use a JTextArea rather than a JLabel.