}else{ // UNIXes (Linux and MAC) go here
popupWeight=MEDIUM_WEIGHT_POPUP;
}
+ } else if (HEAVY_WEIGHT_POPUP.equals(popupWeight) && !MEDIUM_WEIGHT_POPUP.equals(popupWeight)) {
+ throw new IllegalStateException("unknown value of property -Didea.popup.weight: " + popupWeight);
}
if (SystemInfo.isMacOSLeopard) {
}
popupWeight = popupWeight.trim();
+ final boolean heavyWeighPopup = HEAVY_WEIGHT_POPUP.equals(popupWeight);
PopupFactory popupFactory;
final PopupFactory oldFactory = PopupFactory.getSharedInstance();
if (!(oldFactory instanceof OurPopupFactory)) {
- if (HEAVY_WEIGHT_POPUP.equals(popupWeight)) {
- popupFactory = new OurPopupFactory() {
- public Popup getPopup(
- Component owner,
- Component contents,
- int x,
- int y
- ) throws IllegalArgumentException {
- final Point point = fixPopupLocation(contents, x, y);
- if (SystemInfo.isLinux) {
- return new Popup(owner, contents, point.x, point.y){};
- }
- return oldFactory.getPopup(owner, contents, point.x, point.y);
- }
- };
- }
- else if (MEDIUM_WEIGHT_POPUP.equals(popupWeight)) {
- popupFactory = new OurPopupFactory() {
+ popupFactory = new OurPopupFactory() {
+ public Popup getPopup(
+ Component owner,
+ Component contents,
+ int x,
+ int y
+ ) throws IllegalArgumentException {
+ final Point point = fixPopupLocation(contents, x, y);
+ try {
+ final Method method = PopupFactory.class.getDeclaredMethod("setPopupType", int.class);
+ method.setAccessible(true);
+ method.invoke(oldFactory, heavyWeighPopup ? 2 : 1);
- public Popup getPopup(final Component owner, final Component contents, final int x, final int y) throws IllegalArgumentException {
- return createPopup(owner, contents, x, y);
}
-
- private Popup createPopup(final Component owner, final Component contents, final int x, final int y) {
- final Point point = fixPopupLocation(contents, x, y);
- if (SystemInfo.isLinux) {
- return new Popup(owner, contents, point.x, point.y){};
- }
- return oldFactory.getPopup(owner, contents, point.x, point.y);
+ catch (Throwable e) {
+ LOG.error(e);
}
- };
- }
- else {
- throw new IllegalStateException("unknown value of property -Didea.popup.weight: " + popupWeight);
- }
+
+ return oldFactory.getPopup(owner, contents, point.x, point.y);
+ }
+ };
+
PopupFactory.setSharedInstance(popupFactory);
}