专栏首页张泽旭的专栏Java编写银行借存利息计算器

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

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+"");
            
            
            
                }
                
    
        });
    }

    
}

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

我来说两句

0 条评论
登录 后参与评论

相关文章

  • Java编写购物车系统

    张泽旭
  • 【腾讯云的1001种玩法】Nginx + Tomcat 负载均衡配置详解

    Nginx作为反向代理服务器,实现负载均衡。首先浏览器发起请求,到达Nginx,由Nginx将请求地址转发给相应的tomcat服务器,再由tomcat服务器将结...

    张泽旭
  • openstack i版搭建教程

    云计算(cloud computing)是基于互联网的相关服务的增加、使用和交付模式,通常涉及通过互联网来提供动态易扩展且经常是虚拟化的资源。云是网络、互联网的...

    张泽旭
  • 云服务器cvm快速入门教程

    本文主要介绍快速配置云服务器的方法。若快速配置不能满足您的需求,您可参考 自定义配置 Linux 云服务器 文档进行配置。

    勤劳的小蜜蜂
  • Spring MVC中redirect到一个页面,同时带些信息过去进行显示,但是不通过Session方式及URL方式?

    如何在Spring MVC中redirect到一个页面,同时带些信息过去进行显示,但是不通过Session方式及URL方式?

    阿敏总司令
  • 【安富莱二代示波器教程】第9章 示波器设计—自动触发和普通触发

    自带触发和普通触发是示波器设计中比较重要的两个功能,本章节为大家讲解二代示波器中自动触发和普通触发的实现。

    armfly
  • 使用java awt最简单的截屏程序

    QQ的截屏大家都熟悉了。有没有想过自己写个截屏小工具呢?  使用到java的awt做个最简单的截屏小程序。  项目截图: 

    凯哥Java
  • 4.网络编程 总结

    changxin7
  • OAuth2 登陆授权代码示例

    现如今各大互联网公司都提供了自己的开放平台,这给第三方开发者提供了不少机会,这些平台为了让开发者访问平台内部被保护的特定资源,使用了OAuth2作为登陆授权协议...

    java达人
  • 京东荣获第二十届中国专利奖银奖及优秀奖

    12月25日,由国家知识产权局和世界知识产权组织共同主办的第二十届中国专利奖颁奖大会在北京举行。国家知识产权局局长申长雨出席大会并为获奖代表颁奖。

    京东技术

扫码关注云+社区

领取腾讯云代金券