From 8c9aca1a7911abf87c33cf279d0cca4821117a4e Mon Sep 17 00:00:00 2001 From: kuangshuai Date: Mon, 11 Oct 2021 21:13:40 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-60492=20&&=20REPORT-60480=20=E8=A7=A3?= =?UTF-8?q?=E5=86=B3window=E4=B8=8A=E4=B8=8D=E6=98=BE=E7=A4=BA=E5=92=8C?= =?UTF-8?q?=E9=94=99=E4=BD=8D=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/guide/base/GuideView.java | 57 +++++++------------ 1 file changed, 21 insertions(+), 36 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/guide/base/GuideView.java b/designer-base/src/main/java/com/fr/design/mainframe/guide/base/GuideView.java index d6ff17cbc7..aa277adbbf 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/guide/base/GuideView.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/guide/base/GuideView.java @@ -5,17 +5,15 @@ import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.guide.scene.AbstractGuideScene; import com.fr.design.mainframe.guide.scene.GuideScene; import com.fr.design.mainframe.guide.ui.GuideLoadingGlassPane; +import com.fr.design.utils.gui.GUICoreUtils; import javax.swing.JDialog; import javax.swing.SwingUtilities; import java.awt.Color; import java.awt.Graphics; import java.awt.Window; -import java.awt.event.ComponentAdapter; -import java.awt.event.ComponentEvent; -import java.awt.event.ComponentListener; +import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; -import java.awt.event.WindowFocusListener; public class GuideView extends JDialog { private static GuideView guideView; @@ -43,32 +41,19 @@ public class GuideView extends JDialog { this.setLayout(FRGUIPaneFactory.createBorderLayout()); setBg(); this.setGlassPane(new GuideLoadingGlassPane()); - } - - private WindowFocusListener windowFocusListener = new WindowFocusListener() { - @Override - public void windowGainedFocus(WindowEvent e) { - requestFocus(); - setLocationRelativeTo(window); - } - - @Override - public void windowLostFocus(WindowEvent e) { - - } - }; - - private ComponentListener componentListener = new ComponentAdapter() { - @Override - public void componentResized(ComponentEvent e) { - setLocationRelativeTo(window); - } + DesignerContext.getDesignerFrame().addWindowListener(new WindowAdapter() { - @Override - public void componentMoved(ComponentEvent e) { - setLocation(window.getLocation()); - } - }; + @Override + public void windowDeiconified(WindowEvent e) { + if (isVisible()) { + updateGuideViewLocation(); + // window 带透明的dialog在窗口最小化后再打开会不渲染,这边试了下重新设置visible可行 + setVisible(false); + setVisible(true); + } + } + }); + } public GuideView(Window window, Guide guide) { this(window); @@ -98,11 +83,7 @@ public class GuideView extends JDialog { } public void showGuide() { - window.addComponentListener(componentListener); - window.addWindowFocusListener(windowFocusListener); - this.setLocationRelativeTo(window); - this.setSize(window.getSize()); - this.setLocation(window.getLocation()); + updateGuideViewLocation(); this.setVisible(true); if (scene != null) { scene.start(); @@ -112,8 +93,6 @@ public class GuideView extends JDialog { } public void dismissGuide() { - window.removeComponentListener(componentListener); - window.removeWindowFocusListener(windowFocusListener); this.getLayeredPane().removeAll(); revalidate(); repaint(); @@ -127,6 +106,7 @@ public class GuideView extends JDialog { } public void showLoading() { + updateGuideViewLocation(); this.setVisible(true); this.getGlassPane().setVisible(true); } @@ -141,4 +121,9 @@ public class GuideView extends JDialog { } }); } + + private void updateGuideViewLocation() { + GUICoreUtils.centerWindow(window, this); + this.setSize(getSize()); + } }