[Java] 纯文本查看 复制代码package com.cary.ui;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import com.cary.service.Operation;
import javax.swing.JLabel;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.JComboBox;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.border.TitledBorder;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.UIManager;
import java.awt.Color;
import java.awt.Toolkit;
public class FormulaUI extends JFrame implements ItemListener,ActionListener,MouseListener{
/**
*
*/
private static final long serialVersionUID = 1L;
private JPanel contentPane;
private JTextField textField_0;
private JTextField textField_1;
private JTextField textField_2;
private JTextField textField_3;
private JButton button_0;
private JLabel label_4;
private JLabel label_3;
private JLabel label_2;
private JLabel label_1;
private JComboBox comboBox_0;
private JComboBox comboBox_1;
private String a;
private String b;
private String c;
private Operation op;
private JTextField textField_4;
private JTextField textField_5;
private JTextField textField_6;
private JTextField textField_7;
private JButton button_1;
private JLabel label_7;
private JLabel label_8;
private JLabel label_9;
private String d;
private String f;
private String g;
private JComboBox comboBox_2;
private JLabel label_11;
private JTextField textField_8;
private JTextField textField_9;
private JTextField textField_10;
private JTextField textField_11;
private JTextField textField_12;
private JLabel label_10;
private JLabel label_12;
private JLabel label_13;
private JLabel label_14;
private JLabel label_15;
private JButton button_2;
private JLabel label_6;
String[] lixi = {"请选择相应公式进行计算","一次支付终值计算(已知P求F)","一次支付现值计算(已知F求P)","等额支付终值计算(已知A求F)"
,"等额支付现值计算(已知A求P)","偿债年金计算公式(已知F求A)","资金回收计算公式(已知P求A)","实际利率计算公式(已知r求i)"};
String[] jingji = {"请选择相应公式进行计算","总投资收益率","资本金净利润率","利息备付率","偿债备付率","资产负债率","流动比率",
"速动比率","净资产收益率","总资产净利率","总资产周转率","流动资产周转率","资产负债率","资金成本率","经济订货量","低劣化值法经济寿命"};
String[] caiwu = {"请选择相应公式进行计算","附加率法求租金","经营成本计算(1)","经营成本计算(2)","产销量表示的盈亏平衡点","敏感度系数计算","基本预备费",
"材料基价"};
private boolean flag = false;
private String m;
private String n;
private String o;
private String p;
private JMenuItem menuItem_00;
private JMenuItem menuItem_02;
private JMenuItem menuItem_01;
/**
* Create the frame.
*/
public FormulaUI() {
setTitle("飞扬计算器--工程经济");
setIconImage(Toolkit.getDefaultToolkit().getImage("image\\jsq1.png"));
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 590, 800);
JMenuBar menuBar = new JMenuBar();
setJMenuBar(menuBar);
JMenu menu = new JMenu("计算器");
menuBar.add(menu);
menuItem_00 = new JMenuItem("计算器(普通)");
menuItem_00.addActionListener(this);
menu.add(menuItem_00);
JMenu menu_1 = new JMenu("帮助");
menuBar.add(menu_1);
menuItem_01 = new JMenuItem("使用说明");
menuItem_01.addActionListener(this);
menu_1.add(menuItem_01);
JMenu menu_2 = new JMenu("关于");
menuBar.add(menu_2);
menuItem_02 = new JMenuItem("关于计算器");
menuItem_02.addActionListener(this);
menu_2.add(menuItem_02);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
JLabel label_0 = new JLabel(" 工程经济常见公式计算器");
label_0.setFont(new Font("楷体", Font.BOLD, 30));
label_0.setBounds(14, 13, 534, 46);
contentPane.add(label_0);
JPanel panel_0 = new JPanel();
panel_0.setBorder(new TitledBorder(null, "现值与终值及实际利率计算", TitledBorder.LEADING, TitledBorder.TOP, null, null));
panel_0.setBounds(14, 57, 534, 189);
contentPane.add(panel_0);
panel_0.setLayout(null);
JLabel label = new JLabel("现值与终值计算:");
label.setBounds(42, 23, 169, 24);
panel_0.add(label);
label.setFont(new Font("楷体", Font.PLAIN, 20));
comboBox_0 = new JComboBox();
comboBox_0.setBounds(208, 23, 261, 24);
for (int i = 0; i < lixi.length; i++) {
comboBox_0.addItem(lixi[i]);
}
// comboBox_0.addItemListener(this);
comboBox_0.addMouseListener(this);
panel_0.add(comboBox_0);
comboBox_0.setFont(new Font("楷体", Font.PLAIN, 18));
label_1 = new JLabel(" 公式:");
label_1.setBounds(0, 50, 534, 24);
panel_0.add(label_1);
label_1.setFont(new Font("楷体", Font.PLAIN, 18));
label_2 = new JLabel("F=");
label_2.setBounds(61, 87, 72, 33);
panel_0.add(label_2);
label_2.setFont(new Font("楷体", Font.PLAIN, 20));
textField_0 = new JTextField();
textField_0.setBounds(81, 87, 90, 33);
panel_0.add(textField_0);
textField_0.setFont(new Font("宋体", Font.PLAIN, 20));
textField_0.setColumns(10);
label_3 = new JLabel("i=");
label_3.setBounds(208, 87, 72, 33);
panel_0.add(label_3);
label_3.setFont(new Font("楷体", Font.PLAIN, 20));
textField_1 = new JTextField();
textField_1.setBounds(229, 87, 90, 33);
panel_0.add(textField_1);
textField_1.setFont(new Font("宋体", Font.PLAIN, 20));
textField_1.setColumns(10);
label_4 = new JLabel("n=");
label_4.setBounds(351, 87, 72, 33);
panel_0.add(label_4);
label_4.setFont(new Font("楷体", Font.PLAIN, 20));
textField_2 = new JTextField();
textField_2.setBounds(373, 87, 90, 33);
panel_0.add(textField_2);
textField_2.setFont(new Font("宋体", Font.PLAIN, 20));
textField_2.setColumns(10);
button_0 = new JButton("计算结果");
button_0.setBounds(71, 133, 123, 33);
button_0.addActionListener(this);
panel_0.add(button_0);
button_0.setFont(new Font("楷体", Font.PLAIN, 20));
textField_3 = new JTextField();
textField_3.setBounds(199, 133, 251, 33);
panel_0.add(textField_3);
textField_3.setFont(new Font("楷体", Font.PLAIN, 20));
textField_3.setEditable(false);
textField_3.setColumns(10);
JPanel panel_1 = new JPanel();
panel_1.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "\u7ECF\u6D4E\u6548\u679C\u8BC4\u4EF7\u53CA\u5DE5\u7A0B\u8D22\u52A1", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
panel_1.setBounds(14, 259, 534, 197);
contentPane.add(panel_1);
panel_1.setLayout(null);
JLabel label_5 = new JLabel("经济效果评价及工程财务:");
label_5.setFont(new Font("楷体", Font.PLAIN, 18));
label_5.setBounds(0, 27, 234, 24);
panel_1.add(label_5);
comboBox_1 = new JComboBox();
comboBox_1.setFont(new Font("楷体", Font.PLAIN, 18));
comboBox_1.setBounds(208, 27, 261, 24);
for (int i = 0; i < jingji.length; i++) {
comboBox_1.addItem(jingji[i]);
}
// comboBox_1.addItemListener(this);
comboBox_1.addMouseListener(this);
panel_1.add(comboBox_1);
label_6 = new JLabel(" 公式:");
label_6.setFont(new Font("楷体", Font.PLAIN, 18));
label_6.setBounds(0, 57, 534, 24);
panel_1.add(label_6);
label_7 = new JLabel("F=");
label_7.setFont(new Font("楷体", Font.PLAIN, 20));
label_7.setBounds(0, 94, 106, 33);
panel_1.add(label_7);
textField_4 = new JTextField();
textField_4.setFont(new Font("宋体", Font.PLAIN, 20));
textField_4.setColumns(10);
textField_4.setBounds(88, 94, 72, 33);
panel_1.add(textField_4);
label_8 = new JLabel("i=");
label_8.setFont(new Font("楷体", Font.PLAIN, 20));
label_8.setBounds(162, 94, 114, 33);
panel_1.add(label_8);
textField_5 = new JTextField();
textField_5.setFont(new Font("宋体", Font.PLAIN, 20));
textField_5.setColumns(10);
textField_5.setBounds(255, 94, 72, 33);
panel_1.add(textField_5);
label_9 = new JLabel("n=");
label_9.setFont(new Font("楷体", Font.PLAIN, 20));
label_9.setBounds(341, 94, 100, 33);
panel_1.add(label_9);
textField_6 = new JTextField();
textField_6.setFont(new Font("宋体", Font.PLAIN, 20));
textField_6.setColumns(10);
textField_6.setBounds(434, 94, 72, 33);
panel_1.add(textField_6);
button_1 = new JButton("计算结果");
button_1.setFont(new Font("楷体", Font.PLAIN, 20));
button_1.setBounds(71, 140, 123, 33);
button_1.addActionListener(this);
panel_1.add(button_1);
textField_7 = new JTextField();
textField_7.setFont(new Font("楷体", Font.PLAIN, 20));
textField_7.setEditable(false);
textField_7.setColumns(10);
textField_7.setBounds(199, 140, 251, 33);
panel_1.add(textField_7);
JPanel panel_2 = new JPanel();
panel_2.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "\u5DE5\u7A0B\u8D22\u52A1\u53CA\u5DE5\u7A0B\u4F30\u4EF7", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
panel_2.setBounds(14, 469, 534, 245);
contentPane.add(panel_2);
panel_2.setLayout(null);
label_10 = new JLabel("工程财务相关计算:");
label_10.setFont(new Font("楷体", Font.PLAIN, 20));
label_10.setBounds(14, 26, 196, 24);
panel_2.add(label_10);
comboBox_2 = new JComboBox();
comboBox_2.setFont(new Font("楷体", Font.PLAIN, 18));
comboBox_2.setBounds(208, 26, 261, 24);
for (int i = 0; i < caiwu.length; i++) {
comboBox_2.addItem(caiwu[i]);
}
// comboBox_2.addItemListener(this);
// comboBox_2.addActionListener(this);
comboBox_2.addMouseListener(this);
panel_2.add(comboBox_2);
label_11 = new JLabel(" 公式:");
label_11.setFont(new Font("楷体", Font.PLAIN, 18));
label_11.setBounds(0, 63, 534, 24);
panel_2.add(label_11);
label_12 = new JLabel("F=");
label_12.setFont(new Font("楷体", Font.PLAIN, 20));
label_12.setBounds(14, 100, 113, 33);
panel_2.add(label_12);
textField_8 = new JTextField();
textField_8.setFont(new Font("宋体", Font.PLAIN, 20));
textField_8.setColumns(10);
textField_8.setBounds(129, 100, 106, 33);
panel_2.add(textField_8);
label_13 = new JLabel("i=");
label_13.setFont(new Font("楷体", Font.PLAIN, 20));
label_13.setBounds(235, 100, 132, 33);
panel_2.add(label_13);
textField_9 = new JTextField();
textField_9.setFont(new Font("宋体", Font.PLAIN, 20));
textField_9.setColumns(10);
textField_9.setBounds(365, 100, 96, 33);
panel_2.add(textField_9);
label_14 = new JLabel("F=");
label_14.setFont(new Font("楷体", Font.PLAIN, 20));
label_14.setBounds(14, 139, 113, 33);
panel_2.add(label_14);
textField_10 = new JTextField();
textField_10.setFont(new Font("宋体", Font.PLAIN, 20));
textField_10.setColumns(10);
textField_10.setBounds(129, 139, 106, 33);
panel_2.add(textField_10);
label_15 = new JLabel("i=");
label_15.setFont(new Font("楷体", Font.PLAIN, 20));
label_15.setBounds(235, 139, 132, 33);
panel_2.add(label_15);
textField_11 = new JTextField();
textField_11.setFont(new Font("宋体", Font.PLAIN, 20));
textField_11.setColumns(10);
textField_11.setBounds(365, 146, 96, 33);
panel_2.add(textField_11);
button_2 = new JButton("计算结果");
button_2.setFont(new Font("楷体", Font.PLAIN, 20));
button_2.setBounds(71, 185, 123, 33);
button_2.addActionListener(this);
panel_2.add(button_2);
textField_12 = new JTextField();
textField_12.setFont(new Font("楷体", Font.PLAIN, 20));
textField_12.setEditable(false);
textField_12.setColumns(10);
textField_12.setBounds(199, 187, 251, 33);
panel_2.add(textField_12);
op = new Operation();
this.setUnit1Visible(false);
this.setUnit2Visible(false);
this.setUnit3Visible(false);
}
/**
* 设置组件显隐性函数
* [url=home.php?mod=space&uid=952169]@Param[/url] b 传入true为显现,传入false为隐藏
*/
private void setUnit1Visible(boolean b){
label_1.setVisible(b);
label_2.setVisible(b);
label_3.setVisible(b);
label_4.setVisible(b);
textField_0.setVisible(b);
textField_1.setVisible(b);
textField_2.setVisible(b);
textField_3.setVisible(b);
button_0.setVisible(b);
}
private void setUnit2Visible(boolean b){
label_6.setVisible(b);
label_7.setVisible(b);
label_8.setVisible(b);
label_9.setVisible(b);
textField_4.setVisible(b);
textField_5.setVisible(b);
textField_6.setVisible(b);
textField_7.setVisible(b);
button_1.setVisible(b);
}
private void setUnit3Visible(boolean b){
label_11.setVisible(b);
label_12.setVisible(b);
label_13.setVisible(b);
label_14.setVisible(b);
label_15.setVisible(b);
textField_8.setVisible(b);
textField_9.setVisible(b);
textField_10.setVisible(b);
textField_11.setVisible(b);
textField_12.setVisible(b);
button_2.setVisible(b);
}
/**
* 清空文本框函数
*/
private void removeUnit1TextField(){
textField_0.setText("");
textField_1.setText("");
textField_2.setText("");
textField_3.setText("");
}
private void removeUnit2TextField(){
textField_4.setText("");
textField_5.setText("");
textField_6.setText("");
textField_7.setText("");
}
private void removeUnit3TextField(){
textField_8.setText("");
textField_9.setText("");
textField_10.setText("");
textField_11.setText("");
textField_12.setText("");
}
/*
* (non-Javadoc)下拉框事件函数
* [url=home.php?mod=space&uid=2660]@see[/url] java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
*/
@SuppressWarnings("static-access")
@Override
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange()== e.DESELECTED) {
if (comboBox_0.getSelectedIndex()==1) {
this.setUnit1Visible(true);
this.removeUnit1TextField();
label_1.setText(" 公式:F = P(1+i)^n 或 F = P(F/P,i,n)");
label_1.setFont(new Font("楷体", Font.PLAIN, 20));
label_2.setText("P=");
label_3.setText("i=");
label_4.setText("n=");
}
else if (comboBox_0.getSelectedIndex()==2) {
this.setUnit1Visible(true);
this.removeUnit1TextField();
label_1.setText(" 公式:P = F(1+i)^(-n) 或 P = F(P/F,i,n)");
label_1.setFont(new Font("楷体", Font.PLAIN, 18));
label_2.setText("F=");
label_3.setText("i=");
label_4.setText("n=");
}
else if (comboBox_0.getSelectedIndex()==3) {
this.setUnit1Visible(true);
this.removeUnit1TextField();
label_1.setText(" 公式:F = A((1+i)^n-1)/i 或 F = A(F/A,i,n)");
label_1.setFont(new Font("楷体", Font.PLAIN, 18));
label_2.setText("A=");
label_3.setText("i=");
label_4.setText("n=");
}
else if (comboBox_0.getSelectedIndex()==4) {
this.setUnit1Visible(true);
this.removeUnit1TextField();
label_1.setText(" 公式:P = A((1+i)^n-1)/(i*(1+i)^n) 或 P = A(P/A,i,n)");
label_1.setFont(new Font("楷体", Font.PLAIN, 18));
label_2.setText("A=");
label_3.setText("i=");
label_4.setText("n=");
}
else if (comboBox_0.getSelectedIndex()==5) {
this.setUnit1Visible(true);
this.removeUnit1TextField();
label_1.setText(" 公式:A = F*i/((1+i)^n-1) 或 A = F(A/F,i,n)");
label_1.setFont(new Font("楷体", Font.PLAIN, 18));
label_2.setText("F=");
label_3.setText("i=");
label_4.setText("n=");
}
else if (comboBox_0.getSelectedIndex()==6) {
this.setUnit1Visible(true);
this.removeUnit1TextField();
label_1.setText(" 公式:A = P*i*(1+i)^n/((1+i)^n-1) 或 A = P(A/P,i,n)");
label_1.setFont(new Font("楷体", Font.PLAIN, 18));
label_2.setText("P=");
label_3.setText("i=");
label_4.setText("n=");
}
else if (comboBox_0.getSelectedIndex()==7) {
this.setUnit1Visible(true);
this.removeUnit1TextField();
label_1.setText(" 公式:i = (1+r/m)^n-1"+" "+"注:r为名义利率,m为计息周期,n为收付周期");
label_1.setFont(new Font("楷体", Font.PLAIN, 16));
label_2.setText("r=");
label_3.setText("m=");
label_4.setText("n=");
}
}
else if (e.getStateChange()==e.SELECTED) {
if (flag) {
if (comboBox_1.getSelectedIndex()==1) {
this.setUnit2Visible(true);
this.removeUnit2TextField();
label_6.setText(" 公式:总投资收益率(ROI)=息税前利润(EBIT)/总投资(TI)");
label_6.setFont(new Font("楷体", Font.PLAIN, 18));
label_7.setText(" EBIT=");
label_8.setText(" TI=");
label_9.setText("");
label_9.setVisible(false);
textField_6.setVisible(false);
}
else if (comboBox_1.getSelectedIndex()==2) {
this.setUnit2Visible(true);
this.removeUnit2TextField();
label_6.setText(" 公式:资本金净利润率(ROE)=净利润(NP)/资本金(EC)");
label_6.setFont(new Font("楷体", Font.PLAIN, 18));
label_7.setText(" NP=");
label_8.setText(" EC=");
label_9.setText("");
label_9.setVisible(false);
textField_6.setVisible(false);
}
else if (comboBox_1.getSelectedIndex()==3) {
this.setUnit2Visible(true);
this.removeUnit2TextField();
label_6.setText(" 公式:利息备付率=息税前利润(EBIT)/当期应付利息(PI)");
label_6.setFont(new Font("楷体", Font.PLAIN, 18));
label_7.setText(" EBIT=");
label_8.setText(" PI=");
label_9.setText("");
label_9.setVisible(false);
textField_6.setVisible(false);
}
else if (comboBox_1.getSelectedIndex()==4) {
this.setUnit2Visible(true);
this.removeUnit2TextField();
label_6.setText(" 公式:偿债备付率=可用于还本付息的资金(EBITDA-TAx)/当期应还本付息的金额(PD)");
label_6.setFont(new Font("楷体", Font.PLAIN, 14));
label_7.setText(" EBITDA=");
label_8.setText(" TAx=");
label_9.setText(" PD=");
label_9.setVisible(true);
textField_6.setVisible(true);
}
else if (comboBox_1.getSelectedIndex()==5) {
this.setUnit2Visible(true);
this.removeUnit2TextField();
label_6.setText(" 公式:资产负债率=负债总额/资产总额");
label_6.setFont(new Font("楷体", Font.PLAIN, 18));
label_7.setText(" 总负债=");
label_8.setText(" 总资产=");
label_9.setText("");
label_9.setVisible(false);
textField_6.setVisible(false);
}
else if (comboBox_1.getSelectedIndex()==6) {
this.setUnit2Visible(true);
this.removeUnit2TextField();
label_6.setText(" 公式:流动比率=流动资产/流动负债");
label_6.setFont(new Font("楷体", Font.PLAIN, 18));
label_7.setText("流动资产=");
label_8.setText("流动负债=");
label_9.setText("");
label_9.setVisible(false);
textField_6.setVisible(false);
}
else if (comboBox_1.getSelectedIndex()==7) {
this.setUnit2Visible(true);
this.removeUnit2TextField();
label_6.setText(" 公式:速动比率=速动资产/流动负债");
label_6.setFont(new Font("楷体", Font.PLAIN, 18));
label_7.setText("速动资产=");
label_8.setText("流动负债=");
label_9.setText("");
label_9.setVisible(false);
textField_6.setVisible(false);
}
else if (comboBox_1.getSelectedIndex()==8) {
this.setUnit2Visible(true);
this.removeUnit2TextField();
label_6.setText(" 公式:净资产收益率=净利润/平均净资产");
label_6.setFont(new Font("楷体", Font.PLAIN, 18));
label_7.setText(" 净利润=");
label_8.setText(" 净资产=");
label_9.setText("");
label_9.setVisible(false);
textField_6.setVisible(false);
}
else if (comboBox_1.getSelectedIndex()==9) {
this.setUnit2Visible(true);
this.removeUnit2TextField();
label_6.setText(" 公式:总资产净利率=息税前利润/平均资产总额");
label_6.setFont(new Font("楷体", Font.PLAIN, 18));
label_7.setText(" EBIT=");
label_8.setText(" 总资产=");
label_9.setText("");
label_9.setVisible(false);
textField_6.setVisible(false);
}
else if (comboBox_1.getSelectedIndex()==10) {
this.setUnit2Visible(true);
this.removeUnit2TextField();
label_6.setText(" 公式:总资产周转率=主营业务收入净额/平均资产总额");
label_6.setFont(new Font("楷体", Font.PLAIN, 18));
label_7.setText("主营收入=");
label_8.setText("资产总额=");
label_9.setText("");
label_9.setVisible(false);
textField_6.setVisible(false);
}
else if (comboBox_1.getSelectedIndex()==11) {
this.setUnit2Visible(true);
this.removeUnit2TextField();
label_6.setText(" 公式:流动资产周转率=流动资产周转额/平均流动资产余额");
label_6.setFont(new Font("楷体", Font.PLAIN, 18));
label_7.setText(" 周转额=");
label_8.setText("资产余额=");
label_9.setText("");
label_9.setVisible(false);
textField_6.setVisible(false);
}
else if (comboBox_1.getSelectedIndex()==12) {
this.setUnit2Visible(true);
this.removeUnit2TextField();
label_6.setText(" 公式:资产负债率=负债总额/资产总额");
label_6.setFont(new Font("楷体", Font.PLAIN, 18));
label_7.setText("负债总额=");
label_8.setText("资产总额=");
label_9.setText("");
label_9.setVisible(false);
textField_6.setVisible(false);
}
else if (comboBox_1.getSelectedIndex()==13) {
this.setUnit2Visible(true);
this.removeUnit2TextField();
label_6.setText(" 公式:资金成本率=年利率*(1-企业所得税率)/(1-借款手续费率)");
label_6.setFont(new Font("楷体", Font.PLAIN, 18));
label_7.setText(" 年利率=");
label_8.setText("所得税率=");
label_9.setText("手续费率=");
// label_9.setVisible(true);
// textField_6.setVisible(true);
}
else if (comboBox_1.getSelectedIndex()==14) {
this.setUnit2Visible(true);
this.removeUnit2TextField();
label_6.setText(" 经济订货量=√(2KD/K2),D为存货需要量,Q为每次进货量,K为每次订货变动成本,K2为单位存储成本");
label_6.setFont(new Font("楷体", Font.PLAIN, 12));
label_7.setText(" K=");
label_8.setText(" D=");
label_9.setText(" K2=");
// label_9.setVisible(true);
// textField_6.setVisible(true);
}
else if (comboBox_1.getSelectedIndex()==15) {
this.setUnit2Visible(true);
this.removeUnit2TextField();
label_6.setText(" 经济寿命(N0)=√(2(P-Ln)λ),P为设备的实际价值,Ln为第n年末的设备净残值,λ为设备的低劣化值");
label_6.setFont(new Font("楷体", Font.PLAIN, 12));
label_7.setText(" P=");
label_8.setText(" Ln=");
label_9.setText(" λ=");
// label_9.setVisible(true);
// textField_6.setVisible(true);
}
}
else {
if (comboBox_2.getSelectedIndex()==1) {
this.setUnit3Visible(true);
this.removeUnit3TextField();
label_11.setText(" 公式:租金(R)=P*(1+N*i)/N+P*r,P为资产的价格,N为还款期数,i为折现率,r为附加率");
label_11.setFont(new Font("楷体", Font.PLAIN, 14));
label_12.setText(" P=");
label_13.setText(" N=");
label_14.setText(" i=");
label_15.setText(" r=");
}
else if (comboBox_2.getSelectedIndex()==2) {
this.setUnit3Visible(true);
this.removeUnit3TextField();
label_11.setText(" 公式1:经营成本=总成本费用-折旧费-摊销费-利息支出");
label_11.setFont(new Font("楷体", Font.PLAIN, 18));
label_12.setText("总成本费用=");
label_13.setText(" 折旧费=");
label_14.setText(" 摊销费=");
label_15.setText(" 利息支出=");
}
else if (comboBox_2.getSelectedIndex()==3) {
this.setUnit3Visible(true);
this.removeUnit3TextField();
label_11.setText(" 公式2:经营成本=外购原材料、燃料动力费+工资福利费+修理费+其他费用");
label_11.setFont(new Font("楷体", Font.PLAIN, 16));
label_12.setText("燃料动力费=");
label_13.setText(" 工资福利费=");
label_14.setText(" 修理费=");
label_15.setText(" 其他费用=");
}
else if (comboBox_2.getSelectedIndex()==4) {
this.setUnit3Visible(true);
this.removeUnit3TextField();
label_11.setText(" 产销量=年固定总成本/(单位产品销售单价-单位产品变动成本-单位产品销售税金及附加)");
label_11.setFont(new Font("楷体", Font.PLAIN, 13));
label_12.setText(" 固定成本=");
label_13.setText(" 销售单价=");
label_14.setText(" 变动成本=");
label_15.setText(" 税金及附加=");
}
else if (comboBox_2.getSelectedIndex()==5) {
this.setUnit3Visible(true);
this.removeUnit3TextField();
label_11.setText(" 敏感度系数(Saf)=(△A/A)/(△F/F),△F/F为不确定因素变化率,△A/A为评价指标变化率");
label_11.setFont(new Font("楷体", Font.PLAIN, 13));
label_12.setText(" △A=");
label_13.setText(" A=");
label_14.setText(" △F=");
label_15.setText(" F=");
}
else if (comboBox_2.getSelectedIndex()==6) {
this.setUnit3Visible(true);
this.removeUnit3TextField();
label_11.setText(" 基本预备费=(设备工器具购置费+建筑安装工程费+工程建设其他费)*基本预备费率");
label_11.setFont(new Font("楷体", Font.PLAIN, 14));
label_12.setText(" 购置费=");
label_13.setText(" 建安费=");
label_14.setText(" 其他费=");
label_15.setText(" 预备费率=");
}
else if (comboBox_2.getSelectedIndex()==7) {
this.setUnit3Visible(true);
this.removeUnit3TextField();
label_11.setText(" 材料基价=[(供应价格+运杂费)*(1+运输损耗率)]*(1+采购保管费率)");
label_11.setFont(new Font("楷体", Font.PLAIN, 17));
label_12.setText(" 供应价格=");
label_13.setText(" 运杂费=");
label_14.setText("运输损耗率=");
label_15.setText("采购保管费率=");
}
}
}
}
/*
* (non-Javadoc)动作事件函数
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*/
@Override
public void actionPerformed(ActionEvent e) {
a = textField_0.getText().trim();
b = textField_1.getText().trim();
c = textField_2.getText().trim();
d = textField_4.getText().trim();
f = textField_5.getText().trim();
g = textField_6.getText().trim();
m = textField_8.getText().trim();
n = textField_9.getText().trim();
o = textField_10.getText().trim();
p = textField_11.getText().trim();
if (e.getSource()== button_0) {
if (comboBox_0.getSelectedIndex()==1) {
String gongshi = a+"*"+"("+"1"+"+"+b+")"+"^"+c;
String result = "";
try {
result = op.getResult(gongshi);
} catch (Exception e1) {
e1.printStackTrace();
}
textField_3.setText(result);
}
else if (comboBox_0.getSelectedIndex()==2) {
String zhongzhi_0 = a+"/"+"("+"1"+"+"+b+")"+"^"+c;
String result = "";
try {
result = op.getResult(zhongzhi_0);
} catch (Exception e1) {
e1.printStackTrace();
}
textField_3.setText(result);
}
else if (comboBox_0.getSelectedIndex()==3) {
String zhongzhi_0 = a+"*"+"("+"("+"1"+"+"+b+")"+"^"+c+"-"+"1"+")"+"/"+b;
String result = "";
try {
result = op.getResult(zhongzhi_0);
} catch (Exception e1) {
e1.printStackTrace();
}
textField_3.setText(result);
}
else if (comboBox_0.getSelectedIndex()==4) {
String zhongzhi_0 = a+"*"+"("+"("+"1"+"+"+b+")"+"^"+c+"-"+"1"+")"+"/"+"("+b+"*"+"("+"1"+"+"+b+")"+"^"+c+")";
String result = "";
try {
result = op.getResult(zhongzhi_0);
} catch (Exception e1) {
e1.printStackTrace();
}
textField_3.setText(result);
}
else if (comboBox_0.getSelectedIndex()==5) {
String zhongzhi_0 = a+"*"+b+"/"+"("+"("+"1"+"+"+b+")"+"^"+c+"-"+"1"+")";
String result = "";
try {
result = op.getResult(zhongzhi_0);
} catch (Exception e1) {
e1.printStackTrace();
}
textField_3.setText(result);
}
else if (comboBox_0.getSelectedIndex()==6) {
String zhongzhi_0 = a+"*"+b+"*"+"("+"1"+"+"+b+")"+"^"+c+"/"+"("+"("+"1"+"+"+b+")"+"^"+c+"-"+"1"+")";
String result = "";
try {
result = op.getResult(zhongzhi_0);
} catch (Exception e1) {
e1.printStackTrace();
}
textField_3.setText(result);
}
else if (comboBox_0.getSelectedIndex()==7) {
String zhongzhi_0 = "("+"1"+"+"+a+"/"+b+")"+"^"+c+"-"+"1";
String result = "";
try {
result = op.getResult(zhongzhi_0);
} catch (Exception e1) {
e1.printStackTrace();
}
textField_3.setText(result);
}
}
else if (e.getSource()==button_1) {
if (comboBox_1.getSelectedIndex()==1||comboBox_1.getSelectedIndex()==2||comboBox_1.getSelectedIndex()==3
||comboBox_1.getSelectedIndex()==5||comboBox_1.getSelectedIndex()==6||comboBox_1.getSelectedIndex()==7
||comboBox_1.getSelectedIndex()==8||comboBox_1.getSelectedIndex()==9||comboBox_1.getSelectedIndex()==10
||comboBox_1.getSelectedIndex()==11||comboBox_1.getSelectedIndex()==12) {
String gongshi = d+"/"+f;
String result = "";
try {
result = op.getResult(gongshi);
} catch (Exception e1) {
e1.printStackTrace();
}
textField_7.setText(result);
}
else if (comboBox_1.getSelectedIndex()==4) {
String gongshi = "("+d+"-"+f+")"+"/"+g;
String result = "";
try {
result = op.getResult(gongshi);
} catch (Exception e1) {
e1.printStackTrace();
}
textField_7.setText(result);
}
else if (comboBox_1.getSelectedIndex()==13) {
String gongshi = d+"*"+"("+"1"+"-"+f+")"+"/"+"("+"1"+"-"+g+")";
String result = "";
try {
result = op.getResult(gongshi);
} catch (Exception e1) {
e1.printStackTrace();
}
textField_7.setText(result);
}
else if (comboBox_1.getSelectedIndex()==14) {
String gongshi = "√"+"("+"2"+"*"+d+"*"+f+"/"+g+")";
String result = "";
try {
result = op.getResult(gongshi);
} catch (Exception e1) {
e1.printStackTrace();
}
textField_7.setText(result);
}
}
else if (e.getSource()==button_2) {
if (comboBox_2.getSelectedIndex()==1) {
String gongshi = m+"*"+"("+"1"+"+"+n+"*"+o+")"+"/"+n+"+"+m+"*"+p;
String result = "";
try {
result = op.getResult(gongshi);
} catch (Exception e1) {
e1.printStackTrace();
}
textField_12.setText(result);
}
else if (comboBox_2.getSelectedIndex()==2) {
String gongshi = m+"-"+n+"-"+o+"-"+p;
String result = "";
try {
result = op.getResult(gongshi);
} catch (Exception e1) {
e1.printStackTrace();
}
textField_12.setText(result);
}
else if (comboBox_2.getSelectedIndex()==3) {
String gongshi = m+"+"+n+"+"+o+"+"+p;
String result = "";
try {
result = op.getResult(gongshi);
} catch (Exception e1) {
e1.printStackTrace();
}
textField_12.setText(result);
}
else if (comboBox_2.getSelectedIndex()==4) {
String gongshi = m+"/"+"("+n+"-"+o+"-"+p+")";
String result = "";
try {
result = op.getResult(gongshi);
} catch (Exception e1) {
e1.printStackTrace();
}
textField_12.setText(result);
}
else if (comboBox_2.getSelectedIndex()==5) {
String gongshi = "("+m+"/"+n+")"+"/"+"("+o+"/"+p+")";
String result = "";
try {
result = op.getResult(gongshi);
} catch (Exception e1) {
e1.printStackTrace();
}
textField_12.setText(result);
}
else if (comboBox_2.getSelectedIndex()==6) {
String gongshi = "("+m+"+"+n+"+"+o+")"+"*"+p;
String result = "";
try {
result = op.getResult(gongshi);
} catch (Exception e1) {
e1.printStackTrace();
}
textField_12.setText(result);
}
else if (comboBox_2.getSelectedIndex()==7) {
String gongshi = "("+"("+m+"+"+n+")"+"*"+"("+"1"+"+"+o+")"+")"+"*"+"("+"1"+"+"+p+")";
String result = "";
try {
result = op.getResult(gongshi);
} catch (Exception e1) {
e1.printStackTrace();
}
textField_12.setText(result);
}
}
else if (e.getSource()==menuItem_00) {
this.dispose();
CalculatorUI c = new CalculatorUI();
c.setVisible(true);
c.setLocation(this.getX(), this.getY());
}
else if (e.getSource()==menuItem_01) {
// this.dispose();
Help help = new Help();
help.setVisible(true);
help.setLocation(this.getX(), this.getY()+60);
}
else if (e.getSource()==menuItem_02) {
// this.dispose();
About frame = new About();
frame.setLocation(this.getX(), this.getY()+50);
frame.setVisible(true);
}
}
/*
* (non-Javadoc)鼠标事件函数
* @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
*/
@Override
public void mouseClicked(MouseEvent e) {
if (e.getSource()==comboBox_0) {
comboBox_0.addItemListener(this);
comboBox_1.removeItemListener(this);
comboBox_2.removeItemListener(this);
}
else if (e.getSource()==comboBox_1) {
comboBox_1.addItemListener(this);
comboBox_0.removeItemListener(this);
comboBox_2.removeItemListener(this);
flag = true;
}
else if (e.getSource()==comboBox_2) {
comboBox_2.addItemListener(this);
comboBox_0.removeItemListener(this);
comboBox_1.removeItemListener(this);
flag = false;
}
}
@Override
public void mouseEntered(MouseEvent e) {
if (e.getSource()==comboBox_0) {
comboBox_0.addItemListener(this);
comboBox_1.removeItemListener(this);
comboBox_2.removeItemListener(this);
}
else if (e.getSource()==comboBox_1) {
comboBox_1.addItemListener(this);
comboBox_0.removeItemListener(this);
comboBox_2.removeItemListener(this);
flag = true;
}
else if (e.getSource()==comboBox_2) {
comboBox_2.addItemListener(this);
comboBox_0.removeItemListener(this);
comboBox_1.removeItemListener(this);
flag = false;
}
}
@Override
public void mouseExited(MouseEvent e) {
if (e.getSource()==comboBox_0) {
comboBox_0.addItemListener(this);
comboBox_1.removeItemListener(this);
comboBox_2.removeItemListener(this);
}
else if (e.getSource()==comboBox_1) {
comboBox_1.addItemListener(this);
comboBox_0.removeItemListener(this);
comboBox_2.removeItemListener(this);
flag = true;
}
else if (e.getSource()==comboBox_2) {
comboBox_2.addItemListener(this);
comboBox_0.removeItemListener(this);
comboBox_1.removeItemListener(this);
flag = false;
}
}
@Override
public void mousePressed(MouseEvent e) {
if (e.getSource()==comboBox_0) {
comboBox_0.addItemListener(this);
comboBox_1.removeItemListener(this);
comboBox_2.removeItemListener(this);
}
else if (e.getSource()==comboBox_1) {
comboBox_1.addItemListener(this);
comboBox_0.removeItemListener(this);
comboBox_2.removeItemListener(this);
flag = true;
}
else if (e.getSource()==comboBox_2) {
comboBox_2.addItemListener(this);
comboBox_0.removeItemListener(this);
comboBox_1.removeItemListener(this);
flag = false;
}
}
@Override
public void mouseReleased(MouseEvent e) {
if (e.getSource()==comboBox_0) {
comboBox_0.addItemListener(this);
comboBox_1.removeItemListener(this);
comboBox_2.removeItemListener(this);
}
else if (e.getSource()==comboBox_1) {
comboBox_1.addItemListener(this);
comboBox_0.removeItemListener(this);
comboBox_2.removeItemListener(this);
flag = true;
}
else if (e.getSource()==comboBox_2) {
comboBox_2.addItemListener(this);
comboBox_0.removeItemListener(this);
comboBox_1.removeItemListener(this);
flag = false;
}
}
}