How to open warning dialog box in Java?

I am working on a GUI and I need to bring a warning dialog box when a certain action happens.

In order to open this warning dialog box, I tried to use this code that I found on a web site but it did not work:

             // Customized MessageDialog with configured buttons
                MessageDialog dialog = new MessageDialog(shell, "My Title", null,
                    "My message", MessageDialog.ERROR, new String[] { "First",
                  "Second", "Third" }, 0);

Open in new window

The problem is MessageDialog cannot be resolved to a type and Eclipse does not recommend me to add any missing library.

What am I doing wrong in here? How can I open a warning dialog box?

This is the website that I used is:

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mccarlIT Business Systems Analyst / Software DeveloperCommented:
Do you need the specially customised buttons? Or are you just after a plain warning message type dialog box?

If you don't need the customised buttons, rather than using the JFace's MessageDialog, have you tried just using a standard SWT MessageBox as demonstrated in the first code example on the page that you linked too?
TolgarAuthor Commented:
I don't need any fancy customized buttons but I would like to have a message on the dialog box and a ok button to close it.

So do you think I can still use swt message box?
mccarlIT Business Systems Analyst / Software DeveloperCommented:
So do you think I can still use swt message box?
I can't see why not. As I said, the link that you posted gives a small example of creating/opening this, you would probably just want to change the icon style from ICON_QUESTION to ICON_WARNING if that is what you want (Refer to the javadoc that I linked to above, for all possible values)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
zzynxSoftware engineerCommented:
Have a look at this article How to Make Dialogs
zzynxSoftware engineerCommented:
Thanx 4 axxepting
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.