前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Java编写银行借存利息计算器

Java编写银行借存利息计算器

作者头像
张泽旭
发布2018-12-10 16:48:22
1.9K0
发布2018-12-10 16:48:22
举报
文章被收录于专栏:张泽旭的专栏
代码语言:javascript
复制
import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.xml.soap.Text;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedWriter;
import javax.swing.JLabel;
import javax.swing.JButton;
import javax.swing.JTextField;
import javax.swing.JComboBox;
import javax.swing.DefaultComboBoxModel;
public class lishu extends JFrame{
    private JPanel contentPane;
    private JTextField textField;
    private JTextField textField_1;
    private JTextField textField_3;
    private JTextField textField_4;
    private JTextField textField_5;
    private JTextField textField_6;
    private JTextField textField_2;
    private JTextField textField_7;
    private JTextField textField_8;
    private JTextField textField_9;
    private JTextField textField_10;
    private JTextField textField_11;
    private JTextField textField_12;
    private JPanel panel;
    private JLabel lblNewLabel;
    private JPanel panel_2;
    private JButton btnNewButton;
    private JPanel panel_3;
    private JPanel panel_4;
    private JPanel panel_8;
    private JLabel lblNewLabel_1;
    private JPanel panel_9;
    private JLabel lblNewLabel_2;
    private JPanel panel_5;
    private JPanel panel_10;
    private JLabel lblNewLabel_3;
    private JButton bu;
    private JComboBox comboBox;
    public static void main(String[] args) {
    
                    lishu frame = new lishu();
        
    
    }
    public lishu() {
        setTitle("银行借存利息计算器");
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setBounds(100, 100, 500, 478);
        contentPane = new JPanel();
        contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
        setContentPane(contentPane);
        contentPane.setLayout(new GridLayout(0, 1, 2, 0));
        
        panel = new JPanel();
        contentPane.add(panel);
        panel.setLayout(new BorderLayout(0, 0));
        
        lblNewLabel = new JLabel("存款利息计算");
        panel.add(lblNewLabel, BorderLayout.NORTH);
        
        panel_2 = new JPanel();
        panel.add(panel_2, BorderLayout.SOUTH);
        
        btnNewButton = new JButton("计算");
    
            
        panel_2.add(btnNewButton);
        
        panel_3 = new JPanel();
        panel.add(panel_3, BorderLayout.CENTER);
        panel_3.setLayout(new GridLayout(0, 1, 4, 0));
        
        panel_4 = new JPanel();
        panel_3.add(panel_4);
        panel_4.setLayout(new GridLayout(1, 0, 0, 0));
        
        panel_8 = new JPanel();
        panel_4.add(panel_8);
        
        lblNewLabel_1 = new JLabel("存款金额");
        panel_8.add(lblNewLabel_1);
        
        textField = new JTextField();
        panel_8.add(textField);
        textField.setColumns(10);
        
        JLabel lblNewLabel_16 = new JLabel("元");
        panel_8.add(lblNewLabel_16);
        
        JLabel label_3 = new JLabel("");
        panel_8.add(label_3);
        
        panel_9 = new JPanel();
        panel_4.add(panel_9);
        
        lblNewLabel_2 = new JLabel("到期利息");
        panel_9.add(lblNewLabel_2);
        
        textField_1 = new JTextField();
        panel_9.add(textField_1);
        textField_1.setColumns(10);
        
        panel_5 = new JPanel();
        panel_3.add(panel_5);
        panel_5.setLayout(new GridLayout(1, 0, 0, 0));
        
        panel_10 = new JPanel();
        panel_5.add(panel_10);
        
        lblNewLabel_3 = new JLabel("存款时间");
        panel_10.add(lblNewLabel_3);
        
        comboBox = new JComboBox();
        comboBox.setModel(new DefaultComboBoxModel(new String[] {"1", "2", "3"}));
        panel_10.add(comboBox);
        
        JLabel label = new JLabel("年");
        panel_10.add(label);
        
        JPanel panel_11 = new JPanel();
        panel_5.add(panel_11);
        
        JLabel lblNewLabel_4 = new JLabel("到期本息");
        panel_11.add(lblNewLabel_4);
        
        textField_3 = new JTextField();
        panel_11.add(textField_3);
        textField_3.setColumns(10);
        
        JPanel panel_6 = new JPanel();
        panel_3.add(panel_6);
        panel_6.setLayout(new GridLayout(1, 0, 0, 0));
        
        JPanel panel_12 = new JPanel();
        panel_6.add(panel_12);
        
        JLabel lblNewLabel_5 = new JLabel("存款利率");
        panel_12.add(lblNewLabel_5);
        
        textField_4 = new JTextField();
        panel_12.add(textField_4);
        textField_4.setColumns(10);
        
        JLabel label_1 = new JLabel("%");
        panel_12.add(label_1);
        
        JPanel panel_13 = new JPanel();
        panel_6.add(panel_13);
        
        JLabel lblNewLabel_6 = new JLabel("到期时间");
        panel_13.add(lblNewLabel_6);
        
        textField_5 = new JTextField();
        panel_13.add(textField_5);
        textField_5.setColumns(10);
        
        JPanel panel_7 = new JPanel();
        panel_3.add(panel_7);
        panel_7.setLayout(new GridLayout(1, 0, 0, 0));
        
        JPanel panel_14 = new JPanel();
        panel_7.add(panel_14);
        
        JLabel lblNewLabel_7 = new JLabel("起始时间");
        panel_14.add(lblNewLabel_7);
        
        textField_6 = new JTextField();
        panel_14.add(textField_6);
        textField_6.setColumns(10);
        
        JPanel panel_15 = new JPanel();
        panel_7.add(panel_15);
        
        JPanel panel_1 = new JPanel();
        contentPane.add(panel_1);
        panel_1.setLayout(new BorderLayout(0, 0));
        
        JLabel lblNewLabel_8 = new JLabel("存款利息计算");
        panel_1.add(lblNewLabel_8, BorderLayout.NORTH);
        
        JPanel panel_16 = new JPanel();
        panel_1.add(panel_16, BorderLayout.SOUTH);
        
         bu = new JButton("计算");
        
        panel_16.add(bu);
//        bu.addActionListener(this);
        
        JPanel panel_17 = new JPanel();
        panel_1.add(panel_17, BorderLayout.CENTER);
        panel_17.setLayout(new GridLayout(0, 1, 4, 0));
        
        JPanel panel_18 = new JPanel();
        panel_17.add(panel_18);
        panel_18.setLayout(new GridLayout(1, 0, 0, 0));
        
        JPanel panel_22 = new JPanel();
        panel_18.add(panel_22);
        
        JLabel lblNewLabel_9 = new JLabel("贷款金额");
        panel_22.add(lblNewLabel_9);
        
        textField_2 = new JTextField();
        panel_22.add(textField_2);
        textField_2.setColumns(10);
        
        JLabel lblNewLabel_17 = new JLabel("元");
        panel_22.add(lblNewLabel_17);
        
        JPanel panel_23 = new JPanel();
        panel_18.add(panel_23);
        
        JLabel lblNewLabel_10 = new JLabel("应还利息");
        panel_23.add(lblNewLabel_10);
        
        textField_7 = new JTextField();
        panel_23.add(textField_7);
        textField_7.setColumns(10);
        
        JPanel panel_19 = new JPanel();
        panel_17.add(panel_19);
        panel_19.setLayout(new GridLayout(1, 0, 0, 0));
        
        JPanel panel_26 = new JPanel();
        panel_19.add(panel_26);
        
        JLabel lblNewLabel_11 = new JLabel("贷款时间");
        panel_26.add(lblNewLabel_11);
        
        textField_8 = new JTextField();
        panel_26.add(textField_8);
        textField_8.setColumns(10);
        
        JLabel label_2 = new JLabel("%");
        panel_26.add(label_2);
        
        JPanel panel_27 = new JPanel();
        panel_19.add(panel_27);
        
        JLabel lblNewLabel_12 = new JLabel("应还本息");
        panel_27.add(lblNewLabel_12);
        
        textField_9 = new JTextField();
        panel_27.add(textField_9);
        textField_9.setColumns(10);
        
        JPanel panel_20 = new JPanel();
        panel_17.add(panel_20);
        panel_20.setLayout(new GridLayout(1, 0, 0, 0));
        
        JPanel panel_24 = new JPanel();
        panel_20.add(panel_24);
        
        JLabel lblNewLabel_13 = new JLabel("贷款利率");
        panel_24.add(lblNewLabel_13);
        
        textField_10 = new JTextField();
        panel_24.add(textField_10);
        textField_10.setColumns(10);
        
        JPanel panel_25 = new JPanel();
        panel_20.add(panel_25);
        
        JLabel lblNewLabel_14 = new JLabel("还款时间");
        panel_25.add(lblNewLabel_14);
        
        textField_11 = new JTextField();
        panel_25.add(textField_11);
        textField_11.setColumns(10);
        
        JPanel panel_21 = new JPanel();
        panel_17.add(panel_21);
        panel_21.setLayout(new GridLayout(1, 0, 0, 0));
        
        JPanel panel_28 = new JPanel();
        panel_21.add(panel_28);
        
        JLabel lblNewLabel_15 = new JLabel("贷款日期");
        panel_28.add(lblNewLabel_15);
        
        textField_12 = new JTextField();
        panel_28.add(textField_12);
        textField_12.setColumns(10);
        
        JPanel panel_29 = new JPanel();
        panel_21.add(panel_29);
        setVisible(true);
         bu.addActionListener(new ActionListener() {
                 public void actionPerformed(ActionEvent e) {
                     Double i1 = new Double(textField_2.getText());
                    
                    Double i4 = new Double(textField_8.getText());
                    
                        Double i2 = new Double(textField_10.getText());
                    
                        Double i3 = new Double(textField_12.getText());
                    
                    textField_7.setText(i1*i4*i2*0.01+"");
                        textField_9.setText(i1*i4*i2*0.01+i1+"");
                        textField_11.setText(i4+i3+"");
                 
                 }
             });
    btnNewButton.addActionListener(new ActionListener() {
        
            
            @Override
            public void actionPerformed(ActionEvent e) {
                
                 Double i1 = new Double(textField.getText());
                
                Double i4 = new Double(comboBox.getSelectedItem().toString());
                
                    Double i2 = new Double(textField_4.getText());
                
                    Double i3 = new Double(textField_6.getText());
                
                    textField_1.setText(i1*i4*i2*0.01+"");
                    textField_3.setText(i1*i4*i2*0.01+i1+"");
                    textField_5.setText(i4+i3+"");
            
            
            
                }
                
    
        });
    }

    
}
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2017年10月13日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档