Problem with SwingUtilities.invokeLater

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • madhoriya22
    Contributor
    • Jul 2007
    • 251

    Problem with SwingUtilities.invokeLater

    Hi,
    I have one thread, inside which I am calling a method.
    Code:
    new Thread(new Runnable() {
           public void run() {                    
                InvoiceVO returnedInvoiceVO = finalizeHandler.postAndPrint();
                :
                :
    }
    Inside that method I am calling another thread to show a message to user if some exception occurs.
    Code:
    protected InvoiceVO postAndPrint() {   
        	InvoiceVO returnedInvoiceVO = null;
            try {
                returnedInvoiceVO = InvoiceBL.printInvoice(invoiceVO, customerVO);
            } catch (final ApplicationException aerr) {
                   SwingUtilities.invokeLater(new Runnable() {
                    public void run() {                                 
                        clientApplicationContext.getMessageMgr().showMessage(finalizeDialog, 
                        aerr.getUserMessageID(), aerr.getUserMessageParameters(), 7);
                        finalizeDialog.lblErrorMsg.setText("");                   
                    }
                });
            }
            return returnedInvoiceVO;
        }
    Now the problem is that the message is disappearing without being visible to the user(Its like flash). The control is not staying on the message modal window(it should stay there). I am not able to find the exact problem.

    Is the previous thread is completing before the current thread. If this is the case then what could be the solution.

    thanks and regards,
    Amit
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Why not use the SwingWorker for this?
    See if this article helps.

    Comment

    Working...