There are now two examples here: YesNo is a non-modal Dialog, ModalYesNo is only slightly different, but shows how to make the dialog modal. The ModalYesNo example has an additional button in the "main application". You shouldn't be able to use the button until you have answered the dialog's question.
Both examples can be run as stand-alone applications:
java YesNoand
java ModalYesNo
Note: There is an error in the printed version of this example. In the book, YesNo is constructed modal; as it is written it will not work unless it is non-modal. As in the FileDialog example of chapter 10, the show() method of a modal dialog blocks until the dialog has been dispose()ed of. A modal Dialog makes things a little easier because we don't have to go to the trouble of performing the wait() and notify() which accomplish the waiting in the answer() method of our non-modal example. ModalYesNo illustrates this.