Results 1 to 2 of 2
  1. #1
    cool is offline Member
    Join Date
    Nov 2010
    Posts
    20
    Rep Power
    0

    Default Display filenames in frame

    Hi,

    I have a file which keeps updating, i need to show that updations as a log in a frame,

    Have extended the SwingWorker class and in its doInBackground() method i am calling an update function, which opens the file and reads its last line and if last line is not equal to previous string(to avoid duplications) i added that as a Label in frame.

    But problem is the frame shows all labels once the background process is done.

    Can somebody help me, how to show continues log of file names

  2. #2
    eRaaaa is offline Senior Member
    Join Date
    Oct 2010
    Location
    Germany
    Posts
    786
    Rep Power
    5

    Default

    Quote Originally Posted by cool View Post
    and if last line is not equal to previous string(to avoid duplications) i added that as a Label in frame.
    where is this done? in the "update function" ? in the doInBackground method? both would be wrong.
    you should use the publish method with overriding the process method of the swingworker class.
    the process method is invoked from the event dispatch thread, so there are you able to modify your gui / add new labels.

    read Lesson: Concurrency in Swing (The Java™ Tutorials > Creating a GUI With JFC/Swing) and see the example "Simple Background Tasks"

Similar Threads

  1. Replies: 5
    Last Post: 01-27-2010, 09:14 PM
  2. Replies: 7
    Last Post: 11-02-2009, 06:31 PM
  3. i want to display decimal values in frame window
    By santhosh_el in forum AWT / Swing
    Replies: 4
    Last Post: 03-16-2009, 09:07 AM
  4. Replies: 8
    Last Post: 12-29-2008, 07:12 AM
  5. how disable the display of close button on the frame
    By kalanidhi in forum New To Java
    Replies: 6
    Last Post: 11-19-2008, 09:51 AM

Posting Permissions

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