OK and Cancel button not visible in MessageDialog in JFace / SWT

1k views Asked by At

I have a message dialog as follows:

import org.eclipse.jface.dialogs.MessageDialog


public void openQuestion(Shell parentShell, String title, String question, final int iconStyle){
MessageDialog dialog = new MessageDialog(
                    parentShell,
                    title,
                    getTitleIcon(iconStyle),
                    question,
                    iconStyle,
                    new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL },
                    0
                    ) {
                        @Override
                        public Image getImage() {
                            return getIcon(iconStyle);
                        }
            };

return dialog.open() == IDialogConstants.OK_ID;
    }

Here when I pass question(parameter) as a small string, I'm able to see OK, Cancel buttons in the dialog. But on the other hand, when I pass question(parameter) as a large string in the message dialog, OK and Cancel buttons are not visible in the dialog. They get hidden. Is there any way that the OK and Cancel buttons be displayed always??

1

There are 1 answers

0
Sarfaraz Khan On BEST ANSWER

No matter what I try ,not able to reproduce your issue.Its working perfectly fine for me even for big multi line string.Attached is the screen shot enter image description here

I guess there is some problem with the layout or size of the shell Object that you are passing Shell parentShell try sending null to the method just for the sake of testing the issue openQuestion(null, "Hello Testing", "Test String,1")

Also if you need my test code for reference here