复利计算器01

Posted Blac狼

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了复利计算器01相关的知识,希望对你有一定的参考价值。

package JSQ;

import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.Font;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.Color;

public class FuLiJiSuanQi extends JFrame {

/**
*
*/
private static final long serialVersionUID = 1L;
private JPanel contentPane;
private JTextField textField_1;
private JTextField textField_2;
private JTextField textField;
private JTextField textField_3;
private JLabel label_1;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
FuLiJiSuanQi frame = new FuLiJiSuanQi();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}

/**
* Create the frame.
*/
public FuLiJiSuanQi() {
setTitle("\u590D\u5229\u8BA1\u7B97\u5668");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);

JLabel label = new JLabel("\u5B58\u6B3E\uFF08\u4E07\uFF09:");
label.setFont(new Font("宋体", Font.PLAIN, 16));
label.setBounds(5, 22, 90, 15);
contentPane.add(label);

textField = new JTextField();
textField.setBounds(105, 20, 130, 21);
contentPane.add(textField);
textField.setColumns(10);
//x=textField.getText();

label_1 = new JLabel("\u5229\u7387( %):");
label_1.setFont(new Font("宋体", Font.PLAIN, 16));
label_1.setBounds(5, 75, 81, 15);
contentPane.add(label_1);

textField_1 = new JTextField();
textField_1.setBounds(105, 45, 130, 21);
contentPane.add(textField_1);
textField_1.setColumns(10);

JLabel label_2 = new JLabel("\u5E74\u9650(\u5E74):");
label_2.setFont(new Font("宋体", Font.PLAIN, 16));
label_2.setBounds(5, 47, 104, 15);
contentPane.add(label_2);

textField_2 = new JTextField();
textField_2.setBounds(105, 73, 130, 21);
contentPane.add(textField_2);
textField_2.setColumns(10);

JButton btnNewButton = new JButton("\u5229\u606F");
btnNewButton.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
double capital=Double.parseDouble(textField.getText());
double year=Double.parseDouble(textField_1.getText());
double rate=Double.parseDouble(textField_2.getText());
double sum=capital*Math.pow((1+rate/100),year);
textField_3.setText(Double.toString(sum));
}
});
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
}
});
btnNewButton.setBounds(5, 120, 69, 23);
contentPane.add(btnNewButton);

textField_3 = new JTextField();
textField_3.setForeground(new Color(127, 255, 212));
textField_3.setEnabled(false);
textField_3.setBounds(105, 121, 130, 21);
contentPane.add(textField_3);
textField_3.setColumns(10);
}
}技术分享

以上是关于复利计算器01的主要内容,如果未能解决你的问题,请参考以下文章

复利计算器

复利计算器2.0

0318-复利计算3

复利运算2.0

复利计算总结

对复利计算器和股票投资的总结