package com.intellij.ui.popup;
import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.ui.popup.util.PopupUtil;
import com.intellij.util.ReflectionUtil;
import javax.swing.*;
import java.awt.*;
-import java.lang.reflect.Method;
public interface PopupComponent {
public PopupComponent getPopup(Component owner, Component content, int x, int y) {
final PopupFactory factory = PopupFactory.getSharedInstance();
- try {
- final Method method = PopupFactory.class.getDeclaredMethod("setPopupType", int.class);
- method.setAccessible(true);
- method.invoke(factory, 2);
+ final int oldType = PopupUtil.getPopupType(factory);
+ PopupUtil.setPopupType(factory, 2);
+ final Popup popup = factory.getPopup(owner, content, x, y);
+ if (oldType >= 0) PopupUtil.setPopupType(factory, oldType);
- }
- catch (Throwable e) {
- LOG.error(e);
- }
-
- return new AwtPopupWrapper(factory.getPopup(owner, content, x, y));
+ return new AwtPopupWrapper(popup);
}
public boolean isNativePopup() {