JDialog to JFrame - thoughts pls

Discussion in 'Java' started by Ike, Feb 27, 2004.

  1. Ike

    Ike Guest

    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
    MessageDialog(owner.gguser,owner.frame/*RalphVince.Misc.RalphFunctions.getJF
    rameForComponent(this)*/, type, message);
    /////////////////////////// THIS IS WHERE EXECUTION USED TO 'WAIT' UNTIL
    dialog was closed /////////////////////
    if (!dialog.display()) {
    // Return if dialog was cancelled.
    return;
    }
    } catch (Exception e) {
    showError("Unable to send message.", false);
    return;
    }

    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.setRecipient(Message.RecipientType.TO,addy);
    newMessage.setSubject(dialog.getSubject());
    newMessage.setSentDate(new Date());
    newMessage.setText(dialog.getContent());

    // Send new message.
    Transport.send(newMessage);
    } catch (Exception e) {
    showError("Unable to send message.", false);
    }
    }
     
    Ike, Feb 27, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. James
    Replies:
    1
    Views:
    794
    Paul Lutus
    Sep 20, 2004
  2. Guest
    Replies:
    6
    Views:
    7,208
    G Winstanley
    Oct 1, 2004
  3. jakester
    Replies:
    3
    Views:
    1,833
    jakester
    Apr 3, 2007
  4. Ross
    Replies:
    1
    Views:
    370
  5. Replies:
    3
    Views:
    725
    FredK
    Aug 27, 2012
Loading...

Share This Page