CODEXE

JFace message dialog

JFace message dialog

JFace message dialog

import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;


public class Test {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Display d = new Display();
		Shell s = new Shell(d);
		s.setSize(200, 100);
		s.setLayout(new FillLayout(SWT.VERTICAL));
		//TODO: Add UI
		Button btn = new Button(s, SWT.NONE);
		btn.setText("Show...");
		btn.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(SelectionEvent event) {
				MessageDialog dialog = new MessageDialog(s, "JFace Message Dialog", null,
						"There is an error!", MessageDialog.ERROR, new String[] { "Btn1",
						"Btn2", "Btn3" }, 0);
					int result = dialog.open();
					System.out.println(result);
			   
			}
		});
		
		//UI End
		s.open();

		while (!s.isDisposed()) {
		  if (!d.readAndDispatch())
			d.sleep();
		}
		d.dispose();
	  
	}
}