From 304a522cfb4f379d2a522a52e9c539a69c9bca19 Mon Sep 17 00:00:00 2001 From: "Henry.Wang" Date: Tue, 21 Jul 2020 12:24:45 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-35692=20=E5=9B=BD=E9=99=85=E5=8C=96-?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E8=AE=BE=E7=BD=AE-=E5=8D=95=E4=BD=8D?= =?UTF-8?q?=E6=94=B9=E4=B8=BAINCH=EF=BC=8C=E6=98=BE=E7=A4=BA=E4=B8=8D?= =?UTF-8?q?=E5=85=A8=20=E6=92=A4=E9=94=80=E4=B8=80=E4=BA=9B=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/utils/gui/GUICoreUtils.java | 55 +++++++++---------- 1 file changed, 25 insertions(+), 30 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/utils/gui/GUICoreUtils.java b/designer-base/src/main/java/com/fr/design/utils/gui/GUICoreUtils.java index 9f5c7fbaa9..586047f5ae 100644 --- a/designer-base/src/main/java/com/fr/design/utils/gui/GUICoreUtils.java +++ b/designer-base/src/main/java/com/fr/design/utils/gui/GUICoreUtils.java @@ -27,7 +27,6 @@ import com.fr.design.gui.itextfield.UITextField; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; -import com.fr.design.mainframe.DesignerContext; import com.fr.design.style.color.ColorCell; import com.fr.design.style.color.ColorFactory; import com.fr.design.style.color.ColorSelectBox; @@ -388,35 +387,31 @@ public final class GUICoreUtils { * @param y y坐标 */ public static void showPopupMenu(JPopupMenu popup, Component parentComponent, int x, int y) { - if (popup == null) {// check null. - return; - } - - Point point = new Point(x, y); - SwingUtilities.convertPointToScreen(point, parentComponent); - - Dimension size = popup.getPreferredSize(); - Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); - screen.setSize(screen.getSize().width, screen.height - HEIGHT_GAP); - //父元素右边界的坐标 - int parentComponentRightBorderPosition = parentComponent.getLocationOnScreen().x + parentComponent.getWidth(); - //设计器右边界的坐标 - Rectangle rectangle = DesignerContext.getDesignerFrame().getBounds(); - int designerRightBorderPosition = rectangle.x + rectangle.width; - rectangle = SwingUtilities.getWindowAncestor(parentComponent).getBounds(); - designerRightBorderPosition = Math.max(designerRightBorderPosition, rectangle.x + rectangle.width); - // peter:调整X的高度. - if (point.x + size.width > designerRightBorderPosition && size.width < designerRightBorderPosition) { - x += (parentComponentRightBorderPosition - point.x - size.width); - } - - // peter:调整y高度. - if (point.y + size.height > screen.height && size.height < screen.height) { - y -= size.height; - } - - popup.show(parentComponent, x, y); - } + if (popup == null) {// check null. + return; + } + + Point point = new Point(x, y); + SwingUtilities.convertPointToScreen(point, parentComponent); + + Dimension size = popup.getPreferredSize(); + Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); + screen.setSize(screen.getSize().width, screen.height - HEIGHT_GAP); + + int showOnScreenX = Math.min(screen.width, parentComponent.getLocationOnScreen().x + parentComponent.getWidth()); + + // peter:调整X的高度. + if (point.x + size.width > showOnScreenX && size.width < showOnScreenX) { + x += (showOnScreenX - point.x - size.width); + } + + // peter:调整y高度. + if (point.y + size.height > screen.height && size.height < screen.height) { + y -= size.height; + } + + popup.show(parentComponent, x, y); + } /** * Set enabled.