I went through it, I only posted the subsection of code.
I just read a tutorial on SwingWorker and just tried a very basic example without any additional code or exception handling so I could just focus on understanding SwingWorker and not worry about syntax or errors in other areas.
Here is what I've taken away from the tutorial.
|
Code:
|
SwingWorker worker = new SwingWorker() {
public Object construct() {
getOrders LO = new getOrders();
LO.listOrders();
txtUsername.setText(LO.customerName);
return 0;
}
};
worker.start(); |
So if I understand this correctly, this just splits off into it's own thread so the GUI is not tied up.
The text field still does not update from a function being called in my getOrders class, so I still have to set it referencing a variable in the getOrders class.
That kind of seems like it violates encapsulation but I'm still green on Java. (I started learning Java yesterday, but at least I can interact with my database and make a GUI).
Thanks for your help so far! Can you above and beyond and explain what each line of code you have is doing? The whole "teach a man to fish and he'll eat forever" concept rather than just giving me the code.
Reading the API, reference manual, etc., is very time consuming and much of it I don't fully grasp. I personally learn better jumping right in and using the API and reference manual as a go to book when I get stuck on something.