From 42e9b6320e14e824f34017a5175f1fc9c28f5b72 Mon Sep 17 00:00:00 2001 From: "Henry.Wang" Date: Mon, 20 Jul 2020 10:30:45 +0800 Subject: [PATCH 1/2] =?UTF-8?q?REPORT-35699=20=E5=9B=BD=E9=99=85=E5=8C=96?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AF=B9=E6=8A=A5=E8=A1=A8=E4=B8=8B=E6=8B=89?= =?UTF-8?q?=E6=A1=86=E4=BA=A7=E7=94=9F=E5=BD=B1=E5=93=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/utils/gui/GUICoreUtils.java | 54 ++++++++++--------- 1 file changed, 29 insertions(+), 25 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 586047f5a..3723c775f 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 @@ -387,31 +387,35 @@ 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 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); - } + 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); + } /** * Set enabled.
From 57c22fe43b56ae478d357c29417b79b51303b0f8 Mon Sep 17 00:00:00 2001 From: "Henry.Wang" Date: Mon, 20 Jul 2020 10:38:27 +0800 Subject: [PATCH 2/2] =?UTF-8?q?REPORT-35699=20=E5=9B=BD=E9=99=85=E5=8C=96?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AF=B9=E6=8A=A5=E8=A1=A8=E4=B8=8B=E6=8B=89?= =?UTF-8?q?=E6=A1=86=E4=BA=A7=E7=94=9F=E5=BD=B1=E5=93=8D=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0import?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/utils/gui/GUICoreUtils.java | 1 + 1 file changed, 1 insertion(+) 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 3723c775f..9f5c7fbaa 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,6 +27,7 @@ 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;