getUser null < I expected this 2nd
words1 null <<<<< I expected this last
listener Dad <<<<< this is the correct label for the selected JCheckBox
The nice thing about Standards is that there are so many to choose from!
The nice thing about Standards is that there are so many to choose from!
The nice thing about Standards is that there are so many to choose from!
Originally posted by Gary Down:
Eddie,
firstly thanks for the help.
I understand aout the threads but what is a widget.
What confuses me is that both the first 2 "null" diaplays originate from the "main" of Words1 after WordUser is instantiated but get produced before WordUser Frame is displayed.
I realise that there is 2 threads running and there us no way to tell which one will run first.
How do I get the value back to the "main"?
Gary.
The logic of your application confuses me.......
Regarding the whole "2 threads running issue", that point is moot. You are trying to get information from a variable before that variable has a value. Thus, the NULL being returned. The only way to fix this is to give your String user and value as soon as the variable is created. Or at least before you call getUser().
It doesn't matter how many threads there are or how long you wait before calling getUser(). If you don't give getUser() a value, you will get null.
Get connectionInstantiate WorkUser class
------Get Data from database
------Create JPanel
------Display data as Check Boxes
------show JFrame
Try and Get Value from user variable
The nice thing about Standards is that there are so many to choose from!
The nice thing about Standards is that there are so many to choose from!
Firstly, one day you'll make a great programmer with great job security. Nobody will be able to understand your code so you will have maximum job security.
.
Seondly, threads can be a difficult area and most programmers minimize interaction between threads so as to avoid deadlocks.
A fairly big assumption to make. However it is retrospectively correct as I have more than 20 years successful programming experience in a number of languages. It could be that background that inhibits my understanding of threads. However, the understanding will be achieved and if minimizing interaction between threads is the way to go then I will undertand why
All sarcasm aside,
a simple question, how do you make one thread (in this case the "main") wait on another's (the "swing" thread) completion before the first continues.
As for the comments about simplifying the code, I am open for constructive suggestions (as stated in earlier posts). However, until I get a satisfactory understanding of threads (that is what tis about) I am not too concerned.
Originally posted by Gary Down:
Ok, I understand the point about the "main" thread just being in a loop until thw "swing" thread sets the variable to release it.
Firstly, one day you'll make a great programmer with great job security. Nobody will be able to understand your code so you will have maximum job security.
.
Seondly, threads can be a difficult area and most programmers minimize interaction between threads so as to avoid deadlocks.
A fairly big assumption to make. However it is retrospectively correct as I have more than 20 years successful programming experience in a number of languages. It could be that background that inhibits my understanding of threads. However, the understanding will be achieved and if minimizing interaction between threads is the way to go then I will undertand why
All sarcasm aside,
a simple question, how do you make one thread (in this case the "main") wait on another's (the "swing" thread) completion before the first continues.
As for the comments about simplifying the code, I am open for constructive suggestions (as stated in earlier posts). However, until I get a satisfactory understanding of threads (that is what tis about) I am not too concerned.
Gary,
First of all, I am not trying to be sarcastic. I have seen many programmers like you and once they settle in they do quite well. You are inquisitive and trying to find your own way in swing programming.
If you are trying to plumb the depths of thread management you should pose your question in the threads and synch forum. I have little experience of using threads in swing programming so I feel I cannot really help you with your program.
I do have a little experience using swing, and am writing a program with about 80 major classes. I have to keep things simple to cope with the complexity. This program has a major GUI component and most actions occur as a result of user action through widgets and some timer events.
The only time I would use threads is to offload some of the action to speed up the GUI.
Hope that clears the air.
Ed
The nice thing about Standards is that there are so many to choose from!
You've gotta fight it! Don't give in! Read this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
|