This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
This problem has me absolutely stumped, and even a couple of people I have shown it to.
If I leave in an system.out.println statement given the current state of a boolean expression it will allow me to call another object which creates a frame.
If I take it out, then it doesn't call the next object.
Before, I go on I would like to apologise for the poor code, but it generally works.
This is the main method
This is the method is being called
If anybody could suggest any slightly better code I would appreciate it.
while(myApp.getValidKeyPress() == false)
while(myApp.getIsStringFinished() == false)
are just terrible.
perhaps if you explained exactly what you're trying to achieve we might have better suggestions.
e.g. perhaps a modal dialog might be better if you're trying to get a name/id into your MyApplication class
Joined: Jul 19, 2012
Thanks for the feedback.
I am the first to admit that the code is really brutal and it needs to be tidied up, big time.
The reason why I used the while loops is to get control from the key press. I found that without the while loops there would be no returns back from the called class. When I ran the program it skipped over waiting for a return from the called method which was a gui.
I know the correct method would be to use the invoke later and invoke and wait commands. However, I have been looking for examples in how to use these with called methods, but I haven't found an examples of this.
That just isn't the way to wait for a button press, or a key press, in a Swing program. So there's really no point in trying to make it work. It would be much better to just write an ordinary Swing application which does that.