資源簡介
模擬支付寶記賬本程序
要求:用圖形用戶界面實現。
能實現消費記錄的添加、刪除、查詢、瀏覽等常有功能,消費記錄能夠存儲到文件中,在此基礎上進行創新,增加其他新的功能。

代碼片段和文件信息
import?java.awt.*;
import?java.awt.event.*;
import??java.io.*;
import?java.time.LocalDate;
import?java.time.LocalTime;
import??javax.swing.*;
class?Add?extends?Jframe?implements?ActionListener?{
????//ImageIcon?background?=?new?ImageIcon(“D:\\桌面\\java\\記賬本\\bg2.jpg“);
????JPanel?jPanel;
????JButton?add?=?new?JButton(“添加“);
????JLabel?name?=?new?JLabel(“消費事項“);
????JLabel?cost?=?new?JLabel(“消費金額“);
????JTextField?t1?=?new?JTextField();
????JTextField?t2?=?new?JTextField();
????public?Add(){
????????JLabel?label?=?new?JLabel();
????????label.setBounds(00350280);
????????this.jPanel?=?(JPanel)this.getContentPane();//強制轉換為頂級容器
????????this.jPanel.setOpaque(false);//透明按鈕
????????this.jPanel.setLayout(null);
????????this.getlayeredPane().setLayout(null);
????????this.getlayeredPane().add(label);
????????this.setSize(350280);
????????this.setVisible(true);
????????this.setResizable(false);
????????this.setLocation(650200);
????????this.settitle(“記賬本添加記錄“);
????????this.name.setBounds(60658035);
????????this.cost.setBounds(2206513035);
????????this.jPanel.add(this.name);
????????this.jPanel.add(this.cost);
????????this.t1.setBounds(2011013523);
????????this.t2.setBounds(18011013523);
????????this.jPanel.add(t1);
????????this.jPanel.add(t2);
????????this.add.setBounds(1301508035);
????????this.jPanel.add(this.add);
????????this.add.addActionListener(this);
????}
????public?void?actionPerformed(ActionEvent?e){
????????????if(this.t1.getText().equals(““)||this.t2.getText().equals(““)){
????????????????JOptionPane.showMessageDialog((Component)null“不能為空“);
????????????????return;
????????????}
????????????try{
????????????????double?var?=?Double.parseDouble((this.t2.getText()));
????????????}catch?(Exception?var10){
????????????????JOptionPane.showMessageDialog((Component)null“請輸入數字“);
????????????????return;
????????????}
????????????File?d?=?new?File(“jizhang\\“+this.t1.getText());
????????????if(!d.exists()){
????????????????d.mkdirs();//創建文件夾
????????????}
????????????File?f?=?new?File(d“things.txt“);
????????????if(!f.exists()){
????????????????try?{
????????????????????f.createNewFile();//創建文件
????????????????}?catch?(IOException?e1)?{
????????????????????e1.printStackTrace();
????????????????}
????????????}
????????????File?g?=?new?File(d“cost.txt“);
????????????if(!g.exists()){
????????????????try?{
????????????????????g.createNewFile();
????????????????}?catch?(IOException?e1)?{
????????????????????e1.printStackTrace();
????????????????}
????????????}
????????????File?t?=?new?File(d“time.txt“);
????????????if(!t.exists()){
????????????????try{
????????????????????t.createNewFile();
????????????????}catch?(IOException?e2){
????????????????????e2.printStackTrace();
????????????????}
????????????}
????????????RandomAccessFile?gg;?//用來訪問文件,用seek()訪問
????????????try{
????????????gg?=?new?RandomAccessFile(f“rw“);
????????????gg.seek(gg.length());
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2019-01-09?21:25??記賬本\
?????目錄???????????0??2019-03-05?19:09??記賬本\.idea\
?????文件?????????276??2018-12-18?17:27??記賬本\.idea\misc.xm
?????文件?????????265??2018-12-18?17:27??記賬本\.idea\modules.xm
?????文件????????8915??2018-12-27?18:47??記賬本\.idea\uiDesigner.xm
?????文件???????23605??2019-03-05?19:09??記賬本\.idea\workspace.xm
?????目錄???????????0??2019-01-07?17:57??記賬本\jizhang\
?????目錄???????????0??2018-12-27?09:57??記賬本\jizhang\午餐\
?????文件???????????6??2018-12-27?09:57??記賬本\jizhang\午餐\cost.txt
?????文件??????????14??2018-12-27?09:57??記賬本\jizhang\午餐\things.txt
?????文件??????????40??2018-12-27?09:57??記賬本\jizhang\午餐\time.txt
?????目錄???????????0??2018-12-27?09:57??記賬本\jizhang\晚餐\
?????文件???????????6??2019-01-07?18:54??記賬本\jizhang\晚餐\cost.txt
?????文件??????????14??2019-01-07?18:54??記賬本\jizhang\晚餐\things.txt
?????文件??????????40??2019-01-07?18:54??記賬本\jizhang\晚餐\time.txt
?????目錄???????????0??2018-12-25?12:26??記賬本\out\
?????目錄???????????0??2018-12-25?12:26??記賬本\out\production\
?????目錄???????????0??2019-03-05?18:09??記賬本\out\production\記賬本\
?????文件????????4848??2019-03-05?18:09??記賬本\out\production\記賬本\Add.class
?????文件????????3352??2019-03-05?18:09??記賬本\out\production\記賬本\Delete.class
?????文件????????4071??2019-03-05?18:09??記賬本\out\production\記賬本\denglu.class
?????文件????????6929??2019-03-05?18:09??記賬本\out\production\記賬本\Find.class
?????文件????????1977??2019-03-05?18:09??記賬本\out\production\記賬本\jiemian.class
?????文件????????4240??2019-03-05?18:09??記賬本\out\production\記賬本\zhuce.class
?????目錄???????????0??2019-01-07?18:15??記賬本\src\
?????文件????????4570??2019-01-07?16:23??記賬本\src\Add.java
?????文件????????2458??2019-01-07?16:23??記賬本\src\Delete.java
?????文件????????3253??2019-01-07?16:24??記賬本\src\denglu.java
?????文件????????7874??2019-01-07?16:23??記賬本\src\Find.java
?????文件????????1871??2019-01-07?16:23??記賬本\src\jiemian.java
?????文件????????3743??2019-01-07?18:15??記賬本\src\zhuce.java
............此處省略4個文件信息
- 上一篇:USB原理圖及PCB.zip
- 下一篇:有效去除陰影代碼效果很好.zip
評論
共有 條評論