diff --git a/designer_chart/src/com/fr/design/chart/axis/MinMaxValuePane.java b/designer_chart/src/com/fr/design/chart/axis/MinMaxValuePane.java index 4a9be221de..88a6b528ec 100644 --- a/designer_chart/src/com/fr/design/chart/axis/MinMaxValuePane.java +++ b/designer_chart/src/com/fr/design/chart/axis/MinMaxValuePane.java @@ -42,24 +42,34 @@ public class MinMaxValuePane extends JPanel { double p = TableLayout.PREFERRED; double f = TableLayout.FILL; double[] columnSize = { p, f }; - double[] rowSize = { p, p, p, p}; - Component[][] components = getPanelComponents(); - JPanel panel = TableLayoutHelper.createTableLayoutPane(components ,rowSize,columnSize); + Component[][] components = getPanelComponents(); + JPanel panel = TableLayoutHelper.createTableLayoutPane(components, getRowSize(p), columnSize); this.setLayout(new BorderLayout()); - this.add(panel,BorderLayout.CENTER); - - for(int i = 0; i < components.length; i++) { - ((UICheckBox)components[i][0]).addActionListener(new ActionListener() { + this.add(panel, BorderLayout.CENTER); + addComponentListener(components); + } - @Override - public void actionPerformed(ActionEvent e) { - checkBoxUse(); - } - }); - ChartSwingUtils.addListener((UICheckBox)components[i][0], (UITextField)components[i][1]); - } + protected double[] getRowSize(double p) { + return new double[]{p, p, p, p}; } + protected void addComponentListener(Component[][] components) { + for (int i = 0; i < components.length; i++) { + addListener((UICheckBox) components[i][0]); + ChartSwingUtils.addListener((UICheckBox) components[i][0], (UITextField) components[i][1]); + } + } + + protected void addListener(UICheckBox checkBox) { + checkBox.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + checkBoxUse(); + } + }); + } + protected Component[][] getPanelComponents() { return new Component[][]{ new Component[]{minCheckBox, minValueField}, @@ -100,7 +110,7 @@ public class MinMaxValuePane extends JPanel { if(axis.getMinValue() != null) { minValueField.setText(axis.getMinValue().toString()); } - } + } // 最大值 if (axis.isCustomMaxValue()) { @@ -108,7 +118,7 @@ public class MinMaxValuePane extends JPanel { if(axis.getMaxValue() != null) { maxValueField.setText(axis.getMaxValue().toString()); } - } + } // 主次刻度单位 if (axis.isCustomMainUnit()) { @@ -116,7 +126,7 @@ public class MinMaxValuePane extends JPanel { if(axis.getMainUnit() != null) { mainUnitField.setText(axis.getMainUnit().toString()); } - } + } if(axis.isCustomSecUnit()) { isCustomSecUnitBox.setSelected(true);