I'm trying to achieve something similar to this. Live debug text area.
In my case, I have a scrollPanel which has a textArea. I need to run a bunch of SQL queries and output the query and the result one by one.
private JTextArea uploadProcess = new JTextArea();
I click a button to perform the update, and it has a MouseListener with mouseClicked action.
btnFinish.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent arg0) {
String countNumber = textField.getText();
String mcu = textField_1.getText();
if(!countNumber.isEmpty() && !mcu.isEmpty()) {
if(mcu.length()==12) {
upload(path, countNumber, mcu,environment[env]);
}
} else {
JOptionPane.showMessageDialog(contentPane,
"UPLOAD FAILED!!",
"ERROR!",
JOptionPane.ERROR_MESSAGE);
}
}
});
ps. I know that mouseClicked action is waiting for all the upload method, and then updating.
The upload method:
uploadProcess.setText("Uploading Process Started...\nThere are "+ sqls.size() + " records.\n\n");
Database db = new Database();
db.connect(envo);
int resluts = 0;
for(int i =0; i<sqls.size();i++) {
resluts = db.updateQuery(sqls.get(i));
uploadProcess.append("Query #" + i + "\n " +sqls.get(i));
uploadProcess.append("\n " + resluts + " row(s) updated in " + envo);
sqls.set(i, sqls.get(i) + " \n " + resluts + " row updated.");
}
Any help/advice is helpful.