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