复利计算器2.01
2016-03-14 13:07
405 查看
package JSQ; import java.awt.EventQueue; 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; double capital,year,rate,sum; int tag; /** * 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\u56682.0"); 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); final JLabel label = new JLabel("\u5B58\u6B3E(\u4E07):"); label.setFont(new Font("Microsoft JhengHei", Font.PLAIN, 16)); label.setBounds(62, 85, 90, 15); contentPane.add(label); textField = new JTextField(); textField.setBounds(166, 84, 130, 21); contentPane.add(textField); textField.setColumns(10); label_1 = new JLabel("\u5229\u7387( %):"); label_1.setFont(new Font("Microsoft JhengHei", Font.PLAIN, 16)); label_1.setBounds(62, 142, 81, 15); contentPane.add(label_1); textField_1 = new JTextField(); textField_1.setBounds(166, 115, 130, 21); contentPane.add(textField_1); textField_1.setColumns(10); JLabel label_2 = new JLabel("\u5E74\u9650(\u5E74):"); label_2.setFont(new Font("Microsoft JhengHei", Font.PLAIN, 16)); label_2.setBounds(62, 117, 104, 15); contentPane.add(label_2); textField_2 = new JTextField(); textField_2.setBounds(166, 140, 130, 21); contentPane.add(textField_2); textField_2.setColumns(10); final JButton btnNewButton = new JButton("\u672C\u606F(\u4E07)"); btnNewButton.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { capital=Double.parseDouble(textField.getText()); year=Double.parseDouble(textField_1.getText()); rate=Double.parseDouble(textField_2.getText()); if(tag==1) { sum=capital*Math.pow((1+rate/100),year); } else if(tag==0){ sum=capital*(1+rate/100)*year; } else { 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(53, 181, 90, 23); contentPane.add(btnNewButton); textField_3 = new JTextField(); textField_3.setForeground(new Color(127, 255, 212)); textField_3.setEnabled(false); textField_3.setBounds(166, 182, 130, 21); contentPane.add(textField_3); textField_3.setColumns(10); final JComboBox comboBox = new JComboBox(); comboBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if(comboBox.getSelectedItem().toString().equals("\u5355\u5229\u8BA1\u7B97")) { tag=0; label.setText("\u5B58\u6B3E(\u4E07):"); btnNewButton.setText("\u672C\u606F(\u4E07)"); } else if(comboBox.getSelectedItem().toString().equals("\u590D\u5229\u8BA1\u7B97")) { tag=1; label.setText("\u5B58\u6B3E(\u4E07):"); btnNewButton.setText("\u672C\u606F(\u4E07)"); } else { tag=3; label.setText("\u603B\u989D(\u4E07):"); btnNewButton.setText("\u5E94\u5B58\u91D1\u989D"); } } }); comboBox.setModel(new DefaultComboBoxModel(new String[] {"\u590D\u5229\u8BA1\u7B97", "\u5355\u5229\u8BA1\u7B97", "\u5B58\u94B1\u4F30\u7B97"})); comboBox.setBounds(53, 10, 90, 21); contentPane.add(comboBox); JLabel label_3 = new JLabel("\u529F\u80FD"); label_3.setFont(new Font("Microsoft JhengHei", Font.PLAIN, 16)); label_3.setBounds(10, 13, 54, 15); contentPane.add(label_3); } }
相关文章推荐
- 88. Merge Sorted Array
- 70. Climbing Stairs
- 67. Add Binary
- 66. Plus One
- Spring中LocalSessionFactoryBean与SessionFactory
- ajax请求Url加参数的使用方法
- ViurtualBox配置虚拟机Linux的网络环境
- Visual Stuido 2015 Community 使用 GitHub 插件
- 不小心打开了show children怎么关闭的问题
- Eclipse护眼背景色
- 58. Length of Last Word
- 38. Count and Say
- 27. Remove Element
- 26. Remove Duplicates from Sorted Array
- Linux下简单线程池的实现
- Web系统大规模并发:电商秒杀与抢购
- ModelMap和ModelAndView
- Dom4j工具类
- 《我是一只IT小小鸟》读后感
- 21. Merge Two Sorted Lists