This is a greenhorn question but it is about Swing.
I have a program which is processing and has an error message to display
so it calls a message-display program (so all messages look alike in the application).
The calling program is editing data entered into a JTextField and the processing is
occurring in the actionPerformed area.
I have Focus Listeners on the JTextFields and am processing a selectAll() statement when a
field is focussed on. Also, in the fields in question in this test, I have added a println "Focus Gained jtfieldname".
During execution, the calling program continues on past the message program call even though
the message program has not issued a return. It seems to me that the calling program should wait
for the called message program to complete before continuing on.
The calling program has the following code:
And the message program has the following code to display after the after the
JLabels are defined.
When I run the application and cause the error condition, the following message sequence prints:
At this point, I have not clicked on the Return button in the message program.
But the calling program has continued processing.
After I click on the Return button in the message JFrame, the println displays:
Why does the calling program not wait for the Return button to be pressed in the message program
before continuing on in its processing?
Since Swing is an event-driven library, what you are describing is normal expected behavior. Don't you want to show a modal JDialog here, not a JFrame? The modal dialog will block program flow until it is dealt with.
For example, a runnable demo program:
Joined: Oct 01, 2008
I think I understand it.
I'll give it a test.
Joined: Oct 01, 2008
Pete's program is quite instructive. It shows quickly how the Java processing works.
SO I modified the message program to use JDialog and all is well.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: Program goes past where I think it should wait for Return from called program