Search code examples
javaswteclipse-rcpmessageboxjface

Is there any option to set position of MessageDialog in Jface?


I am using Jface MessageDialogWithToggle.openYesNoQuestion() to pop up the question dialog. But the dialog is not popping up in the center of the application.

Is there any way to make the dialog to display in the center of the application?


Solution

  • The dialog is normally shown centred on the parent shell you specify on the openYesNoQuestion method.

    If you want to centre on some other shell you will have to create a new class extending MessageDialogWithToggle and override the

    protected Point getInitialLocation(Point initialSize)
    

    method to calculate the postion based on that shell.