利用fineui标准,开发设计器的 swing UI
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

43 lines
1.3 KiB

package com.tptj.tool.hg.fineui.swing.element.layout.impl;
import com.tptj.tool.hg.fineui.swing.element.Element;
import javax.swing.*;
import java.awt.*;
import static com.tptj.tool.hg.fineui.swing.element.layout.impl.BaseFineUILayout.MAX_SIZE;
import static com.tptj.tool.hg.fineui.swing.element.layout.impl.BaseFineUILayout.NOT_EXIST;
/**
* @author 秃破天际
* @version 10.0
* Created by 秃破天际 on 2021/11/1
**/
public class CenterLayout extends BoxLayout {
protected Element element;
public CenterLayout(Element target, int axis) {
super(target.getComponent(), axis);
element = target;
}
@Override
public Dimension preferredLayoutSize(Container parent) {
Dimension dim = super.preferredLayoutSize(parent);
int w = element.getRectStyleAttr("width", MAX_SIZE, NOT_EXIST);
int h = element.getRectStyleAttr("height", MAX_SIZE, NOT_EXIST);
Dimension realDim = new Dimension(w, h);
if (w == MAX_SIZE || w == NOT_EXIST) {
realDim.width = dim.width;
}
if (h == MAX_SIZE || h == NOT_EXIST) {
realDim.height = dim.height;
}
return realDim;
}
@Override
public void layoutContainer(Container parent) {
super.layoutContainer(parent);
}
}