I have set a JTable
to initialize at the beginning of the program, and I set it to a DefaultTableModel
:
public DefaultTableModel usernameScraperTableModel = new DefaultTableModel();
private JTable usernameScraperTable;
I then initialize the table inside the constructor as below,
this.usernameScraperTable = new JTable(this.usernameScraperTableModel);
this.usernameScraperTableModel.addColumn("Username");
and then in my actionPerformed(ActionEvent)
for my startButton
, I run a method. If something is collected, it is supposed to add it to the table.
this.usernameScraperTableModel.addRow(new Object[] { user.getName() } );
It works somewhat. During run-time, the table is blank and doesn't show anything. I know this because in my Eclipse console it's working like it's supposed to. But after the method is done running, it then has the JTable
update and all of the names are there.
I'm wondering how I can have my table update in real time inside of an ActionEvent
of a button.
EDIT
Thanks for this. It still doesn't work though. I used WindowBuilder from the Eclipse website, and it's a JFrame. When I click start, the GUI kind of "freezes" (I can't click anything else, can't press the exit button, anything) until the method is done with