I have created a JDialog in NetBeans and a custom constructor as follows:
public AnimatedProgress(java.awt.Frame parent, boolean modal, JTable table) {
super(parent, modal);
initComponents();
setLocationRelativeTo(parent);
progressLabel.setText("Collecting Table Data. . .");
Object[][] data = getJTableData(table); // Simple method to collect data and store in Object[][] array
progressLabel.setText("Processing Data. . .");
processData(data);
progressLabel.setText("Data Processed. . .");
}
Now I called this JDialog as:
new AnimatedProgress(this, true, dataTable).setVisible(True);
My problem is, as Java calls the constructor, all the codes in constructor gets executed first and then the dialog appears with final result.
How can I make my JDialog appears first and then process the methods: getTableData() and processData()??
Here is a sample use of
SwingWorker:Then change you constructor to this:
I didn’t test it, but I hope it works.