Browse Source

REPORT-60492 && REPORT-60480 解决window上不显示和错位问题

research/11.0
kuangshuai 3 years ago
parent
commit
8c9aca1a79
  1. 57
      designer-base/src/main/java/com/fr/design/mainframe/guide/base/GuideView.java

57
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());
}
}

Loading…
Cancel
Save