|
|
|
@ -7,11 +7,6 @@ import javax.swing.JPanel;
|
|
|
|
|
import javax.swing.event.ChangeEvent; |
|
|
|
|
import javax.swing.event.ChangeListener; |
|
|
|
|
import java.awt.BorderLayout; |
|
|
|
|
import java.awt.Component; |
|
|
|
|
import java.awt.Dimension; |
|
|
|
|
import java.awt.FlowLayout; |
|
|
|
|
import java.awt.Font; |
|
|
|
|
import java.awt.FontMetrics; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @author richie |
|
|
|
@ -47,7 +42,6 @@ public class FormulaPaneWhenReserveFormula extends FormulaPane {
|
|
|
|
|
|
|
|
|
|
checkBoxPane.add(reserveCheckBox4Result, BorderLayout.WEST); |
|
|
|
|
checkBoxPane.add(reserveCheckBox4Write, BorderLayout.WEST); |
|
|
|
|
calculatePaneHeightWithCount(checkBoxPane); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@ -66,30 +60,4 @@ public class FormulaPaneWhenReserveFormula extends FormulaPane {
|
|
|
|
|
} |
|
|
|
|
return formula; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 计算一下公式面板textPane的实际高度 |
|
|
|
|
* 目前已知英文国际化下文本较长,右侧check按钮无法正常展示,实际俄文有可能更长,因此写一个换行规则 |
|
|
|
|
* 不影响中文效果 |
|
|
|
|
* |
|
|
|
|
* @param checkBoxPane textPane |
|
|
|
|
*/ |
|
|
|
|
private void calculatePaneHeightWithCount(JPanel checkBoxPane) { |
|
|
|
|
int componentsWidth = 0; |
|
|
|
|
int currentPaneHeight = checkBoxPane.getPreferredSize().height; |
|
|
|
|
int currentPaneWidth = checkBoxPane.getPreferredSize().width; |
|
|
|
|
int hGap = ((FlowLayout) checkBoxPane.getLayout()).getHgap(); |
|
|
|
|
for (Component component : checkBoxPane.getComponents()) { |
|
|
|
|
if(component instanceof UICheckBox) { |
|
|
|
|
Font font = component.getFont(); |
|
|
|
|
FontMetrics fontMetrics = component.getFontMetrics(font); |
|
|
|
|
int width = fontMetrics.stringWidth(((UICheckBox) component).getText()); |
|
|
|
|
componentsWidth += width + hGap; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
int count = (componentsWidth / currentPaneWidth) + 1; |
|
|
|
|
int resultPaneHeight = count * currentPaneHeight; |
|
|
|
|
checkBoxPane.setPreferredSize(new Dimension(currentPaneWidth, resultPaneHeight)); |
|
|
|
|
} |
|
|
|
|
} |