Joe Degler wrote:Hello anybody!
Today I've completly written my Vocabulary program from scratch, dividing things into different classes instead of just two.
That worked fine, but now I'm stuck at a part:
Let me describe what happens.
Program starts, creates a new thread, starts the run() of the main class, main class loads data out of textfiles into ArrayLists, for-loop starts, the gui opens and now the thing happens:
The GUI opens, but, it continues with the whole thing, opening the same gui over and over until it reaches the maximum of X that I told him to be the max before.
Now, I want the program to WAIT at the point where it is, until the user typed the text and then pushed the button to activate the ActionEvent telling the frame to either close or the panel to close and open another panel.
Here is the code, but the gui is not 100% finished. Oh and please mind that most of the words are german.
{code cut out}
Do not forget the main problem, I want the thread to stop at the point after the GUI is set to visible and then continue after the button is pressed.
And as a side-note: Do you see places where I could improve the code? Make it smaller?
Ralph Cook wrote:
Try taking a step back and telling us, in one paragraph, what your program is supposed to do and what it does now. Specific things that puzzle me about the explanation you've written so far:
* Program starts, creates thread, starts run of the main class...
You normally create a thread other than the one you are running in when you want two things to proceed in parallel. You state that the main class loads array lists with data from text files, and I guess that's in the thread you create. What is the other thread doing?
The other does simply nothing. I just made a new one because I wasn't sure if laying the main thread to sleep would cause problems.
* for-loop starts
I gather you wanted something to loop -- what is it? Do you loop once per word the user enters? Once per panel? Once per month?
After all Actions have been done, the programm shall go to sleep for 5 minutes, when it wakes up again it finishes the method's and the loop starts from new.
* it continues with the whole thing, opening the same gui over and over
Now I'm lost -- what is 'the whole thing' you are referring to? Is opening a new gui at all something the program is supposed to do,you just want to control it?
It keeps reopening the same GUI because the loop finishes itself as there is no "Close gui when method is finished"
And the logical guess doesn't make any sense to me either; why would you get rid of a panel and open a neven under your control?
First I want a JTextField Panel which checks if the word is written right, if it's written wrong, the JTextField panel closes and a Panel with JRadioButton is where the other used to be before and more, but all depending on the same princip.
I'm sorry, but trying to read incomplete code in German is something I'm only liable to do if I think I can tell, from your description, the general sort of things I'm looking for.
No problem.
rc
Ralph Cook wrote:The first thing I asked for was a one-paragraph summary of the program. I still have very little idea what the program is about, and none about how it goes about it. Appearing and disappearing panels? "Got to sleep for 5 minutes"?
I realize it's almost a lost art in software engineering, but what we need here is a functional description. How would you describe to a user what the program does?
rc
Paul Clapham wrote:The "return in 5 minutes" is the part of the design I don't understand either. What's the point of that? Why not just ask the next question immediately? Let the user decide if he wants to answer immediately or not.
And this idea of GUIs appearing and disappearing is completely non-standard too. You're designing your application as if you never saw any other applications, which surely isn't the case. As a beginner you should design your applications to work in a standard way, because it's a lot easier to do that. When you have more experience, then you can try writing applications which do weird things.
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |