Results 1 to 2 of 2
  1. #1
    hinkey1 is offline Member
    Join Date
    Sep 2012
    Rep Power

    Default Reading .txt contents and printing them to java GUI

    Hello All,

    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

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Blog Entries
    Rep Power

    Default 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.

Similar Threads

  1. printing problem of all contents of a canvas
    By mitra in forum Advanced Java
    Replies: 0
    Last Post: 08-05-2011, 08:24 AM
  2. Replies: 19
    Last Post: 08-10-2010, 08:36 AM
  3. Replies: 3
    Last Post: 12-03-2009, 10:05 PM
  4. Printing the contents of an array of objects
    By Mr.Paplu in forum New To Java
    Replies: 1
    Last Post: 03-19-2009, 04:49 PM
  5. Printing contents of a web page
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 11-26-2007, 12:37 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts