This discussion is archived
4 Replies Latest reply: Aug 6, 2013 12:47 PM by mKorbel RSS

JButton event requires code to finish before updating JTable

jwadleigh Newbie
Currently Being Moderated

Hi everyone,

 

I need some help with Java. I've been creating my first Java app and hit a wall where cannot find a solution on Google.

 

I have a JFrame with a button called "Start".  The code behind the "Start" button triggers a function (startwork() ) that traverses through log files and then inserts rows into my JTable.  If I call the startwork() function from the Start button action performed event, then when it inserts the rows to the JTable it is not immediately shown... the code has to finish before the JTable is refreshed.  However, if I run the startwork() function as soon as the JFrame is displayed (from the main() function) then I can see the Jtable being populated dynamically as it is inserting the rows.

 

Can someone explain how to allow the user to click on the START button and yet behave correctly to where the JTable is updated properly so that I can see the rows being inserted as it progresses. 

 

Thank you!

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points