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 for the reply. However, I find it strange that I need to write a SwingWorker sub-class for every button in my GUI that wishes to do some meaningful work. No other programming language that I have used does this. In Visual Basic, we simply add a function in the event handler and that is it. It seems overkill to write a SwingWorker class to basically create another thread that runs some code. I don't see why my GUI has to completely freeze just because I run code in an event.