• 复利计算器2.01


      1 package JSQ;
      2 
      3 import java.awt.EventQueue;
      4 
      5 public class FuLiJiSuanQi extends JFrame {
      6 
      7     /**
      8      * 
      9      */
     10     private static final long serialVersionUID = 1L;
     11     private JPanel contentPane;
     12     private JTextField textField_1;
     13     private JTextField textField_2;
     14     private JTextField textField;
     15     private JTextField textField_3;
     16     private JLabel label_1;
     17     double capital,year,rate,sum;
     18     int tag;
     19     /**
     20      * Launch the application.
     21      */
     22     public static void main(String[] args) {
     23         EventQueue.invokeLater(new Runnable() {
     24             public void run() {
     25                 try {
     26                     FuLiJiSuanQi frame = new FuLiJiSuanQi();
     27                     frame.setVisible(true);
     28                 } catch (Exception e) {
     29                     e.printStackTrace();
     30                 }
     31             }
     32         });
     33     }
     34 
     35     /**
     36      * Create the frame.
     37      */
     38     public FuLiJiSuanQi() {
     39         setTitle("u590Du5229u8BA1u7B97u56682.0");
     40         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     41         setBounds(100, 100, 450, 300);
     42         contentPane = new JPanel();
     43         contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
     44         setContentPane(contentPane);
     45         contentPane.setLayout(null);
     46         
     47         final JLabel label = new JLabel("u5B58u6B3E(u4E07):");
     48         label.setFont(new Font("Microsoft JhengHei", Font.PLAIN, 16));
     49         label.setBounds(62, 85, 90, 15);
     50         contentPane.add(label);
     51         
     52         textField = new JTextField();
     53         textField.setBounds(166, 84, 130, 21);
     54         contentPane.add(textField);
     55         textField.setColumns(10);
     56         
     57         label_1 = new JLabel("u5229u7387( %):");
     58         label_1.setFont(new Font("Microsoft JhengHei", Font.PLAIN, 16));
     59         label_1.setBounds(62, 142, 81, 15);
     60         contentPane.add(label_1);
     61         
     62         textField_1 = new JTextField();
     63         textField_1.setBounds(166, 115, 130, 21);
     64         contentPane.add(textField_1);
     65         textField_1.setColumns(10);
     66         
     67         JLabel label_2 = new JLabel("u5E74u9650(u5E74):");
     68         label_2.setFont(new Font("Microsoft JhengHei", Font.PLAIN, 16));
     69         label_2.setBounds(62, 117, 104, 15);
     70         contentPane.add(label_2);
     71         
     72         textField_2 = new JTextField();
     73         textField_2.setBounds(166, 140, 130, 21);
     74         contentPane.add(textField_2);
     75         textField_2.setColumns(10);
     76         
     77         final JButton btnNewButton = new JButton("u672Cu606F(u4E07)");
     78         btnNewButton.addMouseListener(new MouseAdapter() {
     79             @Override
     80             public void mouseClicked(MouseEvent e) {
     81                  capital=Double.parseDouble(textField.getText());
     82                  year=Double.parseDouble(textField_1.getText());
     83                  rate=Double.parseDouble(textField_2.getText());
     84                  if(tag==1)
     85                  {
     86                      sum=capital*Math.pow((1+rate/100),year);
     87                  }
     88                  else if(tag==0){
     89                      sum=capital*(1+rate/100)*year;
     90                 }
     91                  else {
     92                     sum=capital/Math.pow((1+rate/100),year);
     93                 }
     94                 textField_3.setText(Double.toString(sum));
     95             }
     96         });
     97         btnNewButton.addActionListener(new ActionListener() {
     98             public void actionPerformed(ActionEvent e) {
     99             }
    100         });
    101         btnNewButton.setBounds(53, 181, 90, 23);
    102         contentPane.add(btnNewButton);
    103         
    104         textField_3 = new JTextField();
    105         textField_3.setForeground(new Color(127, 255, 212));
    106         textField_3.setEnabled(false);
    107         textField_3.setBounds(166, 182, 130, 21);
    108         contentPane.add(textField_3);
    109         textField_3.setColumns(10);
    110         
    111         final JComboBox comboBox = new JComboBox();
    112         comboBox.addItemListener(new ItemListener() {
    113             public void itemStateChanged(ItemEvent e) {
    114                 if(comboBox.getSelectedItem().toString().equals("u5355u5229u8BA1u7B97"))
    115                 {
    116                     tag=0;
    117                     label.setText("u5B58u6B3E(u4E07):");
    118                     btnNewButton.setText("u672Cu606F(u4E07)");
    119                 }
    120                 else if(comboBox.getSelectedItem().toString().equals("u590Du5229u8BA1u7B97")) {
    121                     tag=1;
    122                     label.setText("u5B58u6B3E(u4E07):");
    123                     btnNewButton.setText("u672Cu606F(u4E07)");
    124                 }
    125                 else {
    126                     tag=3;
    127                     label.setText("u603Bu989D(u4E07):");
    128                     btnNewButton.setText("u5E94u5B58u91D1u989D");
    129                 }
    130             }
    131         });
    132         comboBox.setModel(new DefaultComboBoxModel(new String[] {"u590Du5229u8BA1u7B97", "u5355u5229u8BA1u7B97", "u5B58u94B1u4F30u7B97"}));
    133         comboBox.setBounds(53, 10, 90, 21);
    134         contentPane.add(comboBox);
    135         
    136         JLabel label_3 = new JLabel("u529Fu80FD");
    137         label_3.setFont(new Font("Microsoft JhengHei", Font.PLAIN, 16));
    138         label_3.setBounds(10, 13, 54, 15);
    139         contentPane.add(label_3);
    140     }
    141 }

  • 相关阅读:
    oracle job
    mysql与oracle之间的数据类型转换
    Oracle ORA-02069: 此操作的 global_names 参数必须设置为 TRUE
    oracle sequence 详解
    ORA-08004: 序列 SEQ_XXX.NEXTVAL exceeds MAXVALUE 无法实例化
    How to change Hostname / IP for a Grid Infrastructure Oracle Restart Standalone Configuration (SIHA) (文档 ID 1552810.1)
    oracle-1条updata的故事
    ADAPTIVE LOG FILE SYNC 引起的高Log File Sync警示
    oracle 静默创建数据库
    oracle 中文Linux安装乱码问题
  • 原文地址:https://www.cnblogs.com/LwF39/p/5275354.html
Copyright © 2020-2023  润新知