Skip to content

Instantly share code, notes, and snippets.

@MitI-7
Created March 8, 2015 06:54
Show Gist options
  • Save MitI-7/17adb29673b5325322df to your computer and use it in GitHub Desktop.
Save MitI-7/17adb29673b5325322df to your computer and use it in GitHub Desktop.
import com.intellij.notification.Notification;
import com.intellij.notification.NotificationType;
import com.intellij.notification.Notifications;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.wm.WindowManager;
import javax.swing.*;
public class NotificationSample extends AnAction {
public void actionPerformed(AnActionEvent e) {
// 表示される
Notifications.Bus.notify(new Notification("Sample", "Title1", "content1", NotificationType.INFORMATION));
// ダイアログの表示
SampleDialog sampleDialog = new SampleDialog();
sampleDialog.setLocationRelativeTo(WindowManager.getInstance().getFrame(e.getProject()).getComponents()[0]);
sampleDialog.setVisible(true);
// 表示されない
Notifications.Bus.notify(new Notification("Sample", "Title2", "content2", NotificationType.INFORMATION));
// 表示される
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
Notifications.Bus.notify(new Notification("Sample", "Title3", "content3", NotificationType.INFORMATION));
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment