Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Strange Message Dialog Issue
icon5.gif  Strange Message Dialog Issue [message #523157] Thu, 25 March 2010 11:46 Go to next message
Vijay RajFriend
Messages: 608
Registered: July 2009
Senior Member
I have a message dialog in which i ask a question and based on yes or no i do some additional work.

For some strange reason the MessageDialog.openQuestion method returned always yes without opening the actual dialog .

on analysing i found that this was related to different threads accessing and disposing shells.

I have created a snippet for the same,

Is it an issue????
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class Snippet
{

    public static void main(String[] args)
    {
        Display display = new Display();
        final Shell shell = new Shell(display);
        shell.setSize(400, 300);
        final Shell s = new Shell(shell);
        s.setSize(100, 100);
        s.open();
        Thread t = new Thread(new Runnable()
        {

            @Override
            public void run()
            {
                Display.getDefault().asyncExec(new Runnable()
                {

                    @Override
                    public void run()
                    {
                        boolean openQuestion = MessageDialog.openQuestion(s, "", "Yes Or No");

                        System.out.println(openQuestion);
                    }
                });

            }
        });
        t.start();
        Thread t1 = new Thread(new Runnable()
        {

            @Override
            public void run()
            {
                Display.getDefault().asyncExec(new Runnable()
                {

                    @Override
                    public void run()
                    {
                        s.dispose();
                    }
                });

            }
        });
        t1.start();

        shell.open();
        while (!shell.isDisposed())
        {
            if (!display.readAndDispatch()) display.sleep();
        }
        display.dispose();
    }
}


---------------------
why, mr. Anderson, why, why do you persist?
Because I Choose To.
Regards,
Vijay

[Updated on: Thu, 25 March 2010 11:46]

Report message to a moderator

Re: Stange Message Dialog Issue [message #523358 is a reply to message #523157] Fri, 26 March 2010 06:58 Go to previous message
Praveen  is currently offline Praveen Friend
Messages: 86
Registered: July 2009
Member
vijay wrote:
> Is it an issue????
This question is related to JFace and the best answer can be found out
at JFace newsgroup.
Previous Topic:SWTBot with Eclipse
Next Topic:sticky notes in RCP 3.4
Goto Forum:
  


Current Time: Mon Dec 09 19:05:20 GMT 2019

Powered by FUDForum. Page generated in 0.01741 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top