Skip Navigation

Creating a Basic Text Notification

In a Java editor, create the Notification entity object by adding the code that is shown below. You can also use additional methods in the Notification object. A basic text notification is shown in the following figure.

    final Notification notification = new Notification();


setWindowTitle() adds the title of the notification dialog.

setPriority() adds the priority of the notification. The options are, from least to most important, LOW, NORMAL, HIGH, and CRITICAL.

setContent() adds the text content of the notification.

setLeftSideBarColor() adds the color of the notification. The options are GREEN, RED, and YELLOW.

setNotificationTime() adds the time in milliseconds when you want the notification to be visible to end-users.

  1. Display the notification in a UI thread. Add the code that is shown below to the code in the previous step. If the method that calls createNotification() is already in the SWT UI thread, you do not need the special UiThreadInvoker.

        final INotificationService service = Activator.getDefault().getNotificationService();
        UiThreadInvoker <Object> invoker = new UiThreadInvoker <Object>() {
            protected Object invoke() {
                return null;
  1. Save your Java code.