JDialog to JFrame - thoughts pls



I have recently had to convert a JDialog to a JFrame (this is MessageDialog
dialog in the method below, which is now a JFrame). Initially, when this was
a dialog, once constructed at the line where dialog = new MessageDialog(..),
execution would then wait until the dialog was closed.

However, under a JFrame, this line is executed, and the code runs right on
through, causing trouble of course. I'd like to have execution essentially
"wait," in this method, is it had when dialog was derived from JDialog, and
am querying for your thoughts on how this may be done with as little
rewriting as possible. Thanks, Ike

// Send the specified message.
private void sendMessage(int type, Message message) {
// Display message dialog to get message values.
MessageDialog dialog;
try {
dialog = new
rameForComponent(this)*/, type, message);
/////////////////////////// THIS IS WHERE EXECUTION USED TO 'WAIT' UNTIL
dialog was closed /////////////////////
if (!dialog.display()) {
// Return if dialog was cancelled.
} catch (Exception e) {
showError("Unable to send message.", false);

try {
// Create a new message with values from dialog.
Message newMessage = new MimeMessage(session);
newMessage.setFrom(new InternetAddress(dialog.getFrom()));
Address addy = new InternetAddress(dialog.getTo());
newMessage.setSentDate(new Date());

// Send new message.
} catch (Exception e) {
showError("Unable to send message.", false);


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question