fastcodejava
fastcodejava

Reputation: 41087

MessageDialog in eclipse is not working

I have the following code.

MessageDialog dialog = new MessageDialog(new Shell(), "title", null, "message", MessageDialog.QUESTION, choices, 0);  // choices is an array

It is giving NPE when I do dialog.open(). Any clue?

Upvotes: 1

Views: 314

Answers (3)

Chotka
Chotka

Reputation: 1298

Looks like some of values might be null in choices.

Upvotes: 2

Konstantin Komissarchik
Konstantin Komissarchik

Reputation: 29139

You cannot create a shell like that. You need to access an existing Shell from the context where you are launching the dialog. If you have a reference to any SWT control, you can access the shell from there.

Upvotes: 5

Fabian Steeg
Fabian Steeg

Reputation: 45684

The normal way to use a MessageDialog is via one of the static open* methods, e.g. MessageDialog.openInformation(...). But your issue might be related to the shell you pass.

Upvotes: 2

Related Questions