|
|
|
@ -292,6 +292,24 @@ public final class GUICoreUtils {
|
|
|
|
|
return button; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 将独立弹窗设置在中间位置 适应多屏 跟随设计器主界面 |
|
|
|
|
* 可从父界面获取弹窗应该所在的矩形范围 |
|
|
|
|
* |
|
|
|
|
* @param parent 独立弹窗的父窗口 |
|
|
|
|
* @param win 弹窗自身 |
|
|
|
|
*/ |
|
|
|
|
public static void centerWindow(Component parent, Window win) { |
|
|
|
|
Rectangle rectangle; |
|
|
|
|
if (parent == null) { |
|
|
|
|
rectangle = DesignerContext.getDesignerFrame().getGraphicsConfiguration().getBounds(); |
|
|
|
|
} else { |
|
|
|
|
rectangle = parent.getGraphicsConfiguration().getBounds(); |
|
|
|
|
} |
|
|
|
|
centerWindow(win, rectangle); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 设置一个窗口 |
|
|
|
|
* |
|
|
|
@ -301,7 +319,14 @@ public final class GUICoreUtils {
|
|
|
|
|
// Toolkit.getDefaultToolkit().getScreenSize()在有多个显示器也只能获取到主屏的大小
|
|
|
|
|
// getGraphicsConfiguration().getBounds()能获取多个屏时 设计器主体界面所在屏的大小和对应的坐标
|
|
|
|
|
Rectangle rectangle = win.getGraphicsConfiguration().getBounds(); |
|
|
|
|
centerWindow(win, rectangle); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @param win |
|
|
|
|
* @param rectangle 窗口所在的一个矩形范围 |
|
|
|
|
*/ |
|
|
|
|
public static void centerWindow(Window win, Rectangle rectangle) { |
|
|
|
|
Dimension screenSize = rectangle.getSize(); |
|
|
|
|
|
|
|
|
|
Dimension winSize = win.getSize(); |
|
|
|
@ -315,6 +340,7 @@ public final class GUICoreUtils {
|
|
|
|
|
win.setLocation(rectangle.x + (screenSize.width - winSize.width) / 2, rectangle.y + (screenSize.height - winSize.height) / 2 - WINDOW_GAP); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Gets window/frame to screen center. |
|
|
|
|
* @param owerWin 父窗口 |
|
|
|
|