Browse Source

REPORT-76079【迭代】【起始页】交互问题

7. 展示的效果不够居中
feature/x
Harrison 2 years ago
parent
commit
6bb2e7c4ca
  1. 9
      designer-base/src/main/java/com/fr/design/layout/FRGUIPaneFactory.java

9
designer-base/src/main/java/com/fr/design/layout/FRGUIPaneFactory.java

@ -152,15 +152,18 @@ public class FRGUIPaneFactory {
return new FRGridLayout(nColumn);
}
public static LayoutManager createCenterLayout(JComponent centerBody) {
return createCenterLayout(centerBody, 0.3d);
}
/**
* centerBody 为中心创建一个布局
* 只有当且仅当有一个组件且希望组件 上下左右 居中时使用
* @param centerBody 中心组件
* @return 布局方式
*/
public static LayoutManager createCenterLayout(JComponent centerBody) {
public static LayoutManager createCenterLayout(JComponent centerBody, double factor) {
final double yFactor = 0.30;
return new LayoutManager() {
@Override
@ -186,7 +189,7 @@ public class FRGUIPaneFactory {
int bodyWidth = centerBody.getPreferredSize().width;
int bodyHeight = centerBody.getPreferredSize().height;
int labelX = (width - bodyWidth) / 2;
int labelY = (int) ((height - bodyHeight) * yFactor);
int labelY = (int) ((height - bodyHeight) * factor);
centerBody.setBounds(labelX, labelY, bodyWidth, bodyHeight);
}

Loading…
Cancel
Save