ApplicationManager.getApplication().runReadAction(() -> { MyProjectComponent component = project.getComponent(MyProjectComponent.class); component.doSomething(); });
ApplicationManager.getApplication().invokeLater(() -> { // Do something });
ApplicationManager.getApplication().invokeLater(() -> { String message = "Hello world!"; Notification notification = new Notification("My plugin", "My plugin message", message, NotificationType.INFORMATION); Notifications.Bus.notify(notification); });In this example, we use the ApplicationManager to create a notification and display it using the Notifications bus. To use the com.intellij.openapi.application package, one needs to have the IntelliJ IDEA API library installed, typically found in the lib directory in the IntelliJ IDEA install directory.