Results 1 to 4 of 4
  1. #1
    Skezza is offline Member
    Join Date
    Jul 2010
    Posts
    3
    Rep Power
    0

    Default Swing JLabel Updating (Threading)

    Hi Guys,

    I wrote an application in Java (a while ago now lol) that basically monitors servers. Essentially speaking, it imports from a txt db a list of servers to monitors, and monitors them giving real time updates (all threaded etc).

    Now I have to make a GUI and to be honest my Swing skills ain't so refined and I was wondering if I could nab some help from you experts :D

    Basically (what I have at the moment anyway) I run a while loop on the list of servers (and corresponding thread) which then places a label on the GUI window. However, what I am trying to do is every .5 second update each label with the new values. A general idea of how to do this would be brill. I'm going to have to generate variables for each label I can see, but it is just the updating that is a bit of a pain.

    Thanks

  2. #2
    Skezza is offline Member
    Join Date
    Jul 2010
    Posts
    3
    Rep Power
    0

    Default

    Reading into it a bit more, I'm guessing the use of Swing Timers would be better right? Throw me a bone lol :P Thanks anyway

  3. #3
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,641
    Rep Power
    7

    Default

    If you want regular updates, use a SwingTimer which, when fired, gets the current value and changes the JLabel text.

  4. #4
    Skezza is offline Member
    Join Date
    Jul 2010
    Posts
    3
    Rep Power
    0

    Default

    Excellent. I'll get on it ;-) :-D

    I'm guessing the best way is to keep the server threads out of the GUI class? ;) :D

Similar Threads

  1. Adding a JLabel to a JPanel - jlabel not showing
    By Bongeh in forum New To Java
    Replies: 17
    Last Post: 04-06-2010, 11:02 PM
  2. Threading
    By hedonist in forum Advanced Java
    Replies: 3
    Last Post: 03-13-2010, 02:21 PM
  3. Swing JLabel Problem
    By g123456 in forum New To Java
    Replies: 2
    Last Post: 02-15-2010, 02:17 AM
  4. Threading
    By jon80 in forum New To Java
    Replies: 1
    Last Post: 06-13-2009, 10:53 PM
  5. Threading in EJB
    By java08 in forum Advanced Java
    Replies: 2
    Last Post: 08-12-2008, 11:09 AM

Tags for this Thread

Posting Permissions

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