The thoughts behind my code is that in the Operators(int nr) method the method Label1(nr); gets called, which is in the class and has the code label1Text(txt);. Here is the full code: Hmm wait I just noticed a problem.
There’s nothing stopping you from using standard multi-threading techniques in Swing, and the usual considerations apply. You can find more tutorials, including a complete free video course on multi-threading and courses on Swing, Android and Servlets, on my site Cave of Programming. happy coding.– John Meta: this post is part of the Java Advent Calendar and is licensed under the Creative Commons 3.0 Attribution license.
Useful methods in this class: add Observer(), remove Observer(), notify Observers(), set Changed() and has Changed().
An Observable object can have multiple Observer objects registered with it.
If you have multiple threads accessing the same variables, you’ll need to use synchronized methods or code blocks (or thread-safe classes like Atomic Integer or Array Blocking Queue). As with most user interface APIs, you can’t update the user interface from threads you’ve created yourself. If you like it, please spread the word by sharing, tweeting, FB, G and so on! We are looking for contributors to fill all 24 slot and would love to have your contribution!
Well, as every Java undergraduate knows, you often can, but you shouldn’t.